I use this code in php...
function pushnotificationios( $deviceToken, $message, $badges){
$passphrase = "12345";
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $_SERVER['DOCUMENT_ROOT'].'/include/ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client(
"ssl://gateway.push.apple.com:2195", $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
$body['aps'] = array(
//'badge' => $badges,
'badge' => "+1",
'alert' => $message['message'],
'sound' => 'default',
'content-available' => '1'
);
$body['msg'] =$message;
$payload = json_encode($body);
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
$result = fwrite($fp, $msg, strlen($msg));
//echo "<pre>"; print_r($result);
fclose($fp);
return $result;
}
.pem file and their password is correct. but when i hit this function then only on production mode it give me return false;
$result = pushnotificationios( $deviceToken, $message, $badges);
echo "<pre>"; print_r($result);
And it takes too much time to response.
Currently i am not find any solution.. my api is going to apple and my notifications is not working. The interesting thing is its a chating app and whole app is based on notifications. Its a bad day for me.
Please help if something happen good for me for app.
You can fix an iPhone that's not getting notifications by restarting it or making sure notifications are turned on. You should also make sure your iPhone is connected to the internet so apps can receive notifications. If all else fails, you should try resetting the iPhone — just make sure to back it up first.
Android push notifications sent via GCM / FCM are not reliable due to various issues with GCM's underlying architecture [1] [2] [3]. Push notifications may be delayed, rate-limited, lost in transit, or arrive in a different order than which they were sent.
An iOS push notification is a message that pops up on an Apple device such as an iPhone. Before receiving push notifications from an app, iOS device users must explicitly give permission. Once a user opts-in, mobile app publishers can send push notifications to the users' mobile devices.
To send a test push, go to Mobile Apps > Integrations > Test Push. Use the Apple Sandbox Certificates for Xcode and the Apple Production Certificates when testing from TestFlight.
In production mode don't use sandbox url
$fp = stream_socket_client(
"ssl://gateway.push.apple.com:2195", $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With