Reputation: 1503
In our app, we direct the user to download a .mobileconfig. Originally the problem was Safari just displayed the XML rather than downloaded that, but we got around this with a PHP script (below).
<?php
$file = "http://example.com/myProfile.mobileconfig";
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"$file\"");
readfile ($file);
?>
However we commonly see it where the .mobileconfig is downloaded and automatically it brings up the 'do you wish to install page'. How is that done? Are we missing something in Content-Type?
Thanks,
Sam
Upvotes: 0
Views: 2865
Reputation: 22872
Experienced same problem, the solution is below.
Just set the content type, works like a charm ;)
public function controllerMethod() {
// $config contains generated XML file as string.
$config = $this->generateConfig('apple', Input::all());
// Make response -> attach $config to response
$response = Response::make($config);
// Set headers
$response->headers->set('Content-Type', 'application/x-apple-aspen-config');
$response->headers->set('Content-Disposition', "attachment; filename='mail.mobileconfig'");
return $response;
}
Upvotes: 1