iOS Push Notification

I am using iOS SDK of Backendless to Send Push notification, it is working but not consistent , i tried to update .p12 and it is working when i send notification from local script but not getting message from Backendless Console or iOS SDK.

Hi, Sunil.
Could you clarify some moments.
Have you ever received sent messages using your code?
What is the ‘local script’ that you use to send message? (could you post it here).
Did the change of certificate have any influence on work ?
What version SDK you use?

please try again, we had an issue with connection to apple servers

I am using this php script

<?php // Put your device token here (without spaces): $deviceToken = '8dc2816c8285a35dd839c26378f125432704b8b7780ce567620fb7a8561c64f6'; // Put your private key's passphrase here: $passphrase = 'stylist'; $message = $argv[1]; $url = $argv[2]; if (!$message || !$url) exit('Example Usage: $php newspush.php \'Breaking News!\' \'https://raywenderlich.com\'' . "\n"); //////////////////////////////////////////////////////////////////////////////// $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'WenderCastPush.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); // Open a connection to the APNS server $fp = stream_socket_client( 'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); if (!$fp) exit("Failed to connect: $err $errstr" . PHP_EOL); echo 'Connected to APNS' . PHP_EOL; // Create the payload body $body['aps'] = array( 'alert' => $message, 'sound' => 'default', 'link_url' => $url, ); // Encode the payload as JSON $payload = json_encode($body); // Build the binary notification $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload; // Send it to the server $result = fwrite($fp, $msg, strlen($msg)); if (!$result) echo 'Message not delivered' . PHP_EOL; else echo 'Message successfully delivered' . PHP_EOL; // Close the connection to the server fclose($fp);

It was working few days before, but not working since last 3-4 days. So i create another distribution p12 file for notification

We had an intermittent problem with connecting to the apple servers. The problem has been resolved. Is it working for you now?

It is still not working for me. i tried to send notification from Backendless Console also.

Please try the following:

  1. Send a push notification using API
  2. You will receive message ID in the response.
  3. Use the API to get message status for the message ID. The response should have more information about the error (if it failed)

Regards,
Mark

I am using this method

-(MessageStatus *)publish:(NSString *)channelName message:(id)message publishOptions:(PublishOptions *)publishOptions deliveryOptions:(DeliveryOptions *)deliveryOptions;

In the response i am getting

<MessageStatus> messageId: CFF62320-4BD2-0CAB-FF0E-3A86F25A3000, status: SCHEDULED errorMessage: (null)

It is not displaying any error message and displaying status = SCHEDULED so i think it is not returning any error from API

yeah, you need to make a REST call 5-10 seconds after you publish to get the message status:

https://backendless.com/documentation/messaging/rest/messaging_get_message_status_2.htm

I make the call and i am getting this in the response

{“errorMessage”: "keystore password was incorrect. ",“messageId”: “CFF62320-4BD2-0CAB-FF0E-3A86F25A3000”,“status”: “failed”}

Well, that’s your answer why it is not working. The password your provided in the certificate in Backendless console does not work.

I’ll create new certificates and try it again. Thanks for your help.