在Safari中下载并安装.mobileconfig - 不安装 - OS X(不是iOS)

时间:2013-11-17 23:20:57

标签: php configuration mobile-safari profile provisioning

在我们的应用中,我们指示用户下载.mobileconfig。最初的问题是Safari只显示了XML而不是下载了,但是我们用PHP脚本(下面)解决了这个问题。

<?php
$file = "http://example.com/myProfile.mobileconfig"; 
header("Content-Description: File Transfer"); 
header("Content-Disposition: attachment; filename=\"$file\""); 
readfile ($file); 
?>

但是我们通常会看到下载.mobileconfig的位置,并自动显示“你想安装页面”。怎么做的?我们是否遗漏了Content-Type中的内容?
谢谢, 萨姆

1 个答案:

答案 0 :(得分:0)

遇到同样的问题,解决方法如下 只需设置内容类型,就像魅力一样;)

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;
}