PHP Safari PushNotifications“提取推送通知包失败" [英] PHP Safari PushNotifications "Extracting push notification package failed"

查看:78
本文介绍了PHP Safari PushNotifications“提取推送通知包失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施 safari 通知,并且我已经弄清楚了大部分事情.我正在关注官方教程 https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW1 但我目前收到错误:

<块引用>

提取推送通知包失败

我看过这个话题APNs提取推送通知包失败" 但似乎此人没有得到任何反馈/解决方案.

在此错误之前,我收到推送包的签名验证失败".但我最终通过这个帮助解决了这个问题 苹果网站推送:推送包的签名验证失败,但苹果证书没问题 下载/转换为PEM最新的苹果证书https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer

Website.json 包含以下数据:

<代码>{网站名称":你好",websitePushID":web.com.hello",allowedDomains":[https://hello.com"],"urlFormatString": "https://hello.com/%@",身份验证令牌":01sSggkfAAAqq1seeF0gglzzg",webServiceURL":https://hello.com";}

ma​​nifest.json 包含以下数据:

<代码>{icon.iconset\/icon_16x16.png":{hashType":sha512","hashValue":"d7366c75a9ad9a95ee2e6c6a4642ab6150d01986a870d8726e988c180e373cce7cbda1496150def585fb05e56e382fb05e56e37fb05e56e52fb5c50e5b82fb05e5b3e5c50e52},icon.iconset\/icon_16x16@2x.png":{哈希类型":sha512",哈希值":63287459ef021a8d3fe6a7ee40292446dddea305382713f25e8ff3f40b17d706012c809ebe6238a3652992ba55307d3fc5307d40d40d7d40d7d40d7d407d40713},icon.iconset\/icon_32x32.png":{哈希类型":sha512",hashValue":407027a704b967e57999d45ea68f2ccd156b49c698a4237ac8e60101f4c79388cbebf7242ac93c911f0179d9f9d8c8c8c8f30d308c8f30d9f9d8c8f30d9},icon.iconset\/icon_32x32@2x.png":{哈希类型":sha512","hashValue":"a799fc64879d0d0304eb20b1bb96fe1c1b837e1cbc2d905ad3024b3230337d9f2a6ea41a73b02e91168b97f7d8d8d7ef8d9d8d8d9d8d9d8d8d9d8d8d8d8d9},icon.iconset\/icon_128x128.png":{哈希类型":sha512","hashValue":"e709cbce5e4b4f355a4007a5665ad3b1b020ba81640fbed09db252910c20b956eab6167ae6a3e399b4b1f9ff1cf4d4d8d4d8d4ff1d4d8d4ff1d8d4d84},icon.iconset\/icon_128x128@2x.png":{哈希类型":sha512","hashValue":"1d210614b556267b6d41e1b7ad5d09db90ba77cab2196b85b7bc211873f03ebe3a89a0cf083b61181af0eb69094f083b61181af0fa69094a73e73e73e78c73e73e73e73},网站.json":{哈希类型":sha512","hashValue":"2c050ffb570fab3c4224ad2f08144f4ca9bf09d570f22bf3dc3cabf7c5146e436755bf171befcfa410d8f56ac4139b636c4039b36b408c6139b36e}}

我的文件夹名为pushpackage"持有:

  • website.json
  • manifest.json
  • 签名
  • icon.iconset 文件夹 >6张图片

虽然文档说:

<块引用>

API 的版本.目前,'v2'

Safari 请求是在端点 https://hello.com/v1/pushPackages/web.com.hello 中发出的,这有点奇怪,但是..

最后,上面说的 POST 端点触发:

header('Content-type: application/zip');标头('内容处理:附件;文件名=pushpackage.zip"');echo file_get_contents($file);

zip 看起来不错 - 至少当我打开所有文件时,所有文件都是正确结构的,但我不知道 zip 文件可能有什么问题.有什么想法吗?

解决方案

已解决.

我的代码中有几处错误.

  1. 错误:

<块引用>

提取推送通知包失败

是由于创建 zip 文件时代码中间的 echo ... 引起的.

  1. 错误:

<块引用>

推送包签名验证失败

是由多种因素造成的:

I'm trying to implement safari notifications and I have most things figure out. I'm following the official tutorial https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW1 but I'm currently receiving the error:

Extracting push notification package failed

I have seen this topic APNs "Extracting push notification package failed" but it seems the person didn't get any feedback / solution.

Before this error, I was getting "Signature verification of push package failed." but I endup solving the issue with this help Apple website push: Signature verification of push package failed, but apple certificates are ok and by downloading/converting to PEM the latest Apple certificate https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer

Website.json has the following data:

{
    "websiteName": "hello",
    "websitePushID": "web.com.hello",
    "allowedDomains": ["https://hello.com"],
    "urlFormatString": "https://hello.com/%@",
    "authenticationToken": "01sSggkfAAAqq1seeF0gglzzg",
    "webServiceURL": "https://hello.com"
}

manifest.json has the following data:

{
   "icon.iconset\/icon_16x16.png":{
      "hashType":"sha512",
      "hashValue":"d7366c75a9ad9a95ee2e6c6a4642ab6150d01986a870d8726e988c180e373cce7cbda1496150def585fb05e5b82d9753fabbe03e1e5bf56fce1c94a472bee50b"
   },
   "icon.iconset\/icon_16x16@2x.png":{
      "hashType":"sha512",
      "hashValue":"63287459ef021a8d3fe6a7ee40292446dddea305382713f25e8ff3f40b17d706012c809ebe6238a3652992ba55007f8dd22707b31f4730efc4b9d33baaca593d"
   },
   "icon.iconset\/icon_32x32.png":{
      "hashType":"sha512",
      "hashValue":"407027a704b967e57999d45ea68f2ccd156b49c698a4237ac8e60101f4c79388cbebf7242ac93c911f0176da49a49d12c5eec0f303943ea8f0d99f5d27898d21"
   },
   "icon.iconset\/icon_32x32@2x.png":{
      "hashType":"sha512",
      "hashValue":"a799fc64879d0d0304eb20b1bb96fe1c1b837e1cbc2d905ad3024b3230337d9f2a6ea41a73b02e91168b97fce13dd918f380d95ccd77ef1360e0bb818de8be99"
   },
   "icon.iconset\/icon_128x128.png":{
      "hashType":"sha512",
      "hashValue":"e709cbce5e4b4f355a4007a5665ad3b1b020ba81640fbed09db252910c20b956eab6167ae6a3e399b4b1f9ff1cf8eb4d68de844dd01a39d23fff15b3418ab6c5"
   },
   "icon.iconset\/icon_128x128@2x.png":{
      "hashType":"sha512",
      "hashValue":"1d210614b556267b6d41e1b7ad5d09db90ba77cab2196b85b7bc211873f03ebe3a89a0cf083b61181af0fa6900ba6eb8394f86e4921432a9779fb419c1def7ce"
   },
   "website.json":{
      "hashType":"sha512",
      "hashValue":"2c050ffb570fab3c4224ad2f08144f4ca9bf09d570f22bf3dc3cabf7c5146e436755bf171befcfa410d8f56ac4135b1e03b235197feed6306c5692b793b41668"
   }
}

My folder called "pushpackage" holds:

  • website.json
  • manifest.json
  • signature
  • icon.iconset folder > 6 images

Although the documentation says:

The version of the API. Currently, 'v2'

the Safari requests are being made in the endpoint https://hello.com/v1/pushPackages/web.com.hello, which is kind of strange, but..

Lastly, the POST endpoint said above, triggers:

header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="pushpackage.zip"');

echo file_get_contents($file);

The zip seems fine - at least when I open all the files are correctly structured, but I'm out of ideas about what could be wrong with the zip file. Any ideas?

解决方案

Solved.

I had several things wrong in my code.

  1. The error:

Extracting push notification package failed

Was caused due to an echo ... in the middle of the code when creating the zip file.

  1. The error:

Signature verification of push package failed

Was caused due to several factors:

  • My .p12 certificate was wrong, the .p12 Website Push ID did not match my website.json nor the javascript code. In order to debug / view the data of the certificate I used the command openssl -nokeys -info -in certificate.p12 -passin pass:
  • The certificate AppleWWDRCAG3.cer (that expires in 2030) from the oficial link https://developer.apple.com/support/expiration/ doesn't work. I had to download the file AppleWWDRCA.cer (that expires in 2023) from https://developer.apple.com/certificationauthority/AppleWWDRCA.cer
  • My icons were not created in 72dpi resolution
  • The version used by the Safari to request permissions is the version 1 "v1/pushPackages.." and I was creating the zip file with the manifest.json in the version 2

这篇关于PHP Safari PushNotifications“提取推送通知包失败"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆