3

I followed the manual https://developer.apple.com/notifications/safari-push-notifications/. I use the PHP script to generate the required archive. It is created and downloaded (the structure of the elements is the same as in the manual).

  • all my 'Web Service Endpoints' processing results give the code 200'
  • webServiceURL/version/pushPackages/websitePushID' generates the necessary archive on the download (application/zip for the Content-type header is present)
  • safari downloads it already unzipped folder (meaning the installed header is correct and the file is unzipped normally)
  • the resource(website) that requests "the right to send notifications" is missing in the settings of Safari (Websites-> Notifications), since it has never successfully requested

website.json have correct structure and valid JSON-file...

{
    "websiteName": "Safari Push Demo",
    "websitePushID": "web...",
    "allowedDomains": ["https://..."],
    "urlFormatString": "https://...",
    "authenticationToken": "19f8d7a...be957043",
    "webServiceURL": "https://..."
}

manifest.json have correct structure and valid JSON-file...

{
    "icon.iconset\/icon_16x16.png": "e675cb16...9a38ce0",
    "icon.iconset\/icon_16x16@2x.png": "920249e14c...067305bd0",
    "icon.iconset\/icon_32x32.png": "920249e14c2...305bd0",
    "icon.iconset\/icon_32x32@2x.png": "067fed2988...1b7e5578c21",
    "icon.iconset\/icon_128x128.png": "f4260435....7efeb5fde9",
    "icon.iconset\/icon_128x128@2x.png": "5fe1cd6488...3ebc14654f627",
    "website.json": "eeb81434deab....3bf2d9bd2265"
}

All icons and signature-file presents. The certificate has the appropriate access rights 0644.

For generating and downloading .zip file used this manual Passed simply header as advises the manual from Apple:

header("Content-type: application/zip");
echo file_get_contents($packagePath);#my path to .zip file

Tried and such options: 1)

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/zip");
// header("Content-type: application/octet-stream");#tried and so, too
header("Content-Disposition: attachment; filename=\"pushPackage.zip\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($packagePath));
ob_end_flush();
readfile($packagePath);#my path to .zip file

2)

header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=pushPackage.zip");
header("Content-length: " . filesize($packagePath));
header("Pragma: no-cache");
header("Expires: 0");
readfile($packagePath);

The archive is downloaded and opened, but APNs do not want to accept them and on 'webServiceURL/version/log' I always have {"logs":["Extracting push notification package failed"]}

There is a question with a similar problem, but without solution. I can not write comments because of my reputation, so I decided to ask again with more detailed information about what I tried.

Sergey
  • 53
  • 1
  • 6
  • Did you find a solution? – Linesofcode Nov 27 '20 at 02:22
  • Unfortunately, at that moment we abandoned the implementation of this functionality and did not find a solution. – Sergey Nov 28 '20 at 14:01
  • 1
    I manage to make it working yesterday, see if it helps you https://stackoverflow.com/questions/65031632/php-safari-pushnotifications-extracting-push-notification-package-failed I'm having other problems now https://stackoverflow.com/questions/65043030/javascript-safari-push-notifications-allowed-but-are-always-put-in-deny-mode – Linesofcode Nov 28 '20 at 14:06

0 Answers0