【问题标题】:Downloading AND installing .mobileconfig in Safari - Not installing - OS X (not iOS)在 Safari 中下载和安装 .mobileconfig - 不安装 - OS X(不是 iOS)
【发布时间】:2013-11-17 23:20:56
【问题描述】:

在我们的应用中,我们引导用户下载 .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 中遗漏了什么?
谢谢, 山姆

【问题讨论】:

    标签: php configuration mobile-safari profile provisioning


    【解决方案1】:

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

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

    【讨论】:

    • 嗨。感谢您的回复,但还没有运气。到目前为止,我得到了:&lt;?php $file = "http://freedom-apps.com/armour/config.mobileconfig"; header("Content-Description: File Transfer"); header("Content-Type: application/x-apple-aspen-config"); header("Content-Disposition: attachment; filename=\"$file\""); readfile ($file); ?&gt;,但这仍然不起作用 - 证书只是下载,没有在系统偏好设置中打开。我正在使用 Safari 进行测试。知道发生了什么吗?谢谢!
    • 为了更好地理解,我添加了完整的解决方案和一些 cmets。
    • 我可以检查您是在 Mac OS X 上而不是在 iOS 上执行此操作吗?我试过了,但仍然只是在 Mac 上的 Safari 中下载文件,而不是在系统偏好设置中自动打开。山姆
    • 是的,我在 Mac 上做。我确实创建了邮件配置文件,下载后在 OS X 和 iOS 上配置邮件应用程序。这个配置文件对他们两个都是一样的。添加标题后为我处理它们。
    • Thnx 这完全有效,我在我的 Vue JS 脚本中使用了它。用data:application/x-apple-aspen-config;charset=utf-8,返回了我的数据
    猜你喜欢
    • 2015-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 2015-03-01
    相关资源
    最近更新 更多