Apple Push Notification Service with PHP Script

后端 未结 6 1592
盖世英雄少女心
盖世英雄少女心 2021-01-03 02:22

I\'m trying so send push notifications ton my iPhone (APNS). I read this post and try to implement it. So all my certificates are good (normaly).

Now I have this php

相关标签:
6条回答
  • 2021-01-03 02:26

    To send notifications success fully you have to do 1 more thing.

    Replace $output = json_encode($payload);

    to $payload = json_encode($payload);

    0 讨论(0)
  • 2021-01-03 02:27

    If you have more than one device and you loop through them I found that you have to create a new stream_context_create for each fwrite to prevent apple from closing the connection for a bad token.

    FYI

    0 讨论(0)
  • 2021-01-03 02:30

    You are missing to provice certificate private key. Add this row: stream_context_set_option($streamContext, 'ssl', 'passphrase', $certificatePrivateKey);

    0 讨论(0)
  • 2021-01-03 02:31

    For development certificate you need url

    'ssl://gateway.sandbox.push.apple.com:2195'
    but for production
    'ssl://gateway.push.apple.com:2195'

    0 讨论(0)
  • 2021-01-03 02:32

    no space in device token, strip them

    0 讨论(0)
  • 2021-01-03 02:37

    Strip the spaces from token and even then it's not work then

    $apnsHost = 'gateway.sandbox.push.apple.com';
    

    Remove "sandbox" from this url and it will run.

    0 讨论(0)
提交回复
热议问题