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


Downloading AND installing .mobileconfig in Safari - Not installing - OS X (not iOS)

在我们的应用程序中,我们指导用户下载.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的地方看到它,它会自动显示"你想安装吗"页面。这是怎么做到的?"内容类型"中是否缺少某些内容
谢谢Sam

遇到同样的问题,解决方案如下
只需设置内容类型,作品就很有魅力;)

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