微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pkpass 文件在 Safari Mac 中打开但不在 iPhone 上

如何解决pkpass 文件在 Safari Mac 中打开但不在 iPhone 上

我成功创建了一个通行证,它在我的 MacBook Safari 浏览器上正常打开,但是,当我尝试在我的物理 iPhone 或模拟器上打开它时,它看起来 safari 无法识别通行证文件

在 Mac Safari 上显示Snapshot of how the pass looks when I download it on Mac Safari

在 iPhone 或 Simulator Safari 上显示Sanpshot of how it look on iPhone or Simulator Safari

我已经检查过所有图像资产都包含在包中,并使用了正确的 mime 类型(application/vnd.apple.pkpass),我什至将其添加到了我的服务器 mime.types conf 文件中。

为了解决这个奇怪的问题,还需要检查其他任何事情。

请求和响应头:

URL: http://hayak.localhost/api/request/pass?locale=en-us&uuid=eb5b16db-2a33-4bc8-b3e6-b5dcc5240dfd
Request GET /api/request/pass HTTP/1.1 
Accept: */* 
Accept-Encoding: gzip,deflate
Accept-Language: en-us 
Host: hayak.localhost 
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML,like Gecko) Version/14.0.2 Safari/605.1.15 Connection: keep-alive Referer: http://hayak.localhost/request/vw
Response HTTP/1.1 200 OK 
Content-Type: application/vnd.apple.pkpass
Keep-Alive: timeout=5,max=100 
Pragma: no-cache 
Content-disposition: attachment; filename=CP_3_731585792.pkpass
Last-Modified: Tue,02 Feb 2021 16:00:53 GMT
Cache-Control: public 
Date: Wed,03 Feb 2021 15:18:46 GMT 
Content-Length: 302319 
Connection: Keep-Alive 
Accept-Ranges: bytes
vary: Authorization 
X-Powered-By: PHP/7.4.12 Server: Apache/2.4.46 (Unix) OpenSSL/1.0.2u PHP/7.4.12 mod_wsgi/3.5 Python/2.7.13 mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_perl/2.0.11 Perl/v5.30.1 Content-transfer-encoding: binary X-RateLimit-Limit: 60 X-RateLimit-Remaining: 52 Content-Description: File Transfer

JS(Vue)代码

methods: 
    {
        forceFileDownload(response){
          const url = window.URL.createObjectURL(new Blob([response.data]))
          const link = document.createElement('a')
          link.href = url
          link.setAttribute('download','pass.pkpass') //or any other extension
          document.body.appendChild(link)
          link.click()
        },downloadWithAxios(){
        axios({
          method: 'get',url: '/request/pass',params: {locale: this.$i18n.locale,uuid: this.$store.state.app.request.uuid},responseType: 'arraybuffer'
        })
        .then(response => {
          
          this.forceFileDownload(response)
          
        })
        .catch(() => console.log('error occured'))
      }  
    }

PHP 代码

$path = storage_path().'/passgenerator/'.$pass_identifier.'.pkpass';
        
        return response()->download($path,$pass_identifier.'.pkpass',[
          'Content-transfer-encoding' => 'binary','Content-Description' => 'File Transfer','Content-disposition' => 'attachment; filename=pass.pkpass','Content-length' => strlen($pkpass),'Content-Type' => PassGenerator::getpassMimeType(),'Pragma' => 'no-cache',]);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?