How to send an apple mdm push notification with plain php?

前端 未结 2 1970
鱼传尺愫
鱼传尺愫 2021-01-29 03:10

i\'ve done a apple-mdm-ota-server for IOS so far. The devices deliver me following things to the server (in form of a plist/xml):

-Push Magic Token -Device Token (in b64

2条回答
  •  滥情空心
    2021-01-29 04:00

    I did not see that you included your APNS key when setting up the stream. Here is (roughly) what we do:

    $apns_certkey_path = '/path/to/cert/and/key/file' ;
    $streamContext = stream_context_create();
    stream_context_set_option($streamContext, 'ssl', 'local_cert', $apns_certkey_path);
    
    $apns = stream_socket_client(
      'ssl://' . $apns_url . ':' . $apns_port,
      $error,
      $errorString,
      2, // timeout
      STREAM_CLIENT_CONNECT,
      $streamContext
    );
    
    $payload = json_encode(array('mdm' => $PushMagic));
    $apnsMessage = chr(0)  . chr(0)
                 . chr(32) . base64_decode($ApnsTokenB64)
                 . chr(0)  . chr(strlen($payload)) . $payload;
    fwrite($apns, $apnsMessage);
    

提交回复
热议问题