Friday 15 August 2014

Apple Push notification script not working -


I am using this php script but its output output message delivered successfully but not notification Sending I have already checked the device ID and the certificate that they are correct and working fine with another script

  & lt; Php // Keep your device token here (without spaces):? $ DeviceToken = 'fbf04bf4ace2f1e823016082da3a798cf3ab666ae99a395b65e364eb4c6d6d4a'; // Place your personal key passphrase here: $ passphrase = '123'; // Place your alert message here: $ message = 'A push notification has been sent!'; //////////////////////////////////////////////// ////////////////////////// $ ctx = stream_context_create (); Stream_context_set_option ($ ctx, 'ssl', 'local_cert', 'key.pem'); Stream_context_set_option ($ ctx, 'ssl', 'passphrase', $ passphrase); // Open the connection to the APNS server $ fp = stream_socket_client ('SSL: //gateway.push.apple.com: 2195', $$ err, $ errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ ctx); If (! $ Fp) exit ("Failed to connect: $ err $ errstr". PHP_EOL); 'Connect to APNS' echo PHP_EOL; // payload body $ body ['aps'] = array ('warning' => array ('body' =>; $ message, 'verb-Lok-key' = & gt; 'look', create) , 'Badge' = & gt; 2, 'sound' => 'oven.caf',); // Encrypt payload as JSON $ payload = json_encode ($ body); // Create binary notifications $ msg = chr (0) pack ('n', 32) pack ('H *', $ deviceToken). Pack ('n', strollon ($ payload)). $ Payload; // Send it to server $ result = fwrite ($ fp, $ msg, strlen ($ msg)); Echo "& lt; pre & gt; Results:"; Print_r ($ result); If the 'message was not sent' (! $ Result) echo PHP_EOL; Else 'message successfully delivered' echo PHP_EOL; // Close the server fclose ($ fp) connection; ? & Gt;   

Can anyone help me out of this? Thanks in advance

I encounter similar problems when I first encounter push push notifications

//gateway.sandbox.push.apple.com: The possibility of this is that you are pushing a output instead of pushing a development server will be shuffled to ssl.

This resolves my problem

No comments:

Post a Comment