I am trying to add push notifications to my app. I have am using an ad hoc profile. My appID does not have a wildcard. I am using the following php code...
$deviceToken="****";masked
$time = time();
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev-maui.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
if($apns)
{
echo "Connection Established<br/>";
$payload = array();
$payload['aps'] = array('alert' => 'It works!!', 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
print "sending message :" . $apnsMessage . "<br/>";
print "sending payload :" . $payload . "<br/>";
fwrite($apns, $apnsMessage);
}
else
{
echo "Connection Failed";
echo $errorString;
echo $error;
}
// socket_close($apns);
fclose($apns);
No connection errors are generated. Nothing seems to be coming from the feedback channel.
I got the deviceTokens from the organizer console and an NSLog command. The notifications for this app are showing up in my settings menu.
I have an ATT 3G and an old 2G that I use as an iPod. Neither work.
With no errors to look at, I am out of ideas. Anyone have any insight?
Jennifer
If restarting your phone didn't do the job, one of the most common reasons notifications don't show on Android is because of the notification settings of the app in question. It's possible that you may have mistakenly messed up with the default notification settings, and so now you're not receiving them properly.
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.
PushTry is an online testing tool which helps you to test APNS and GCM online from your browser. This is one of the simple and powerful online push notification testing tool available on the internet. PushTry supports major functionalities to test APNS and GCM. If you want us to add any feature then please contact us.
I finally figured it out. I was using Sandbox with an AdHoc provisioning profile. Ad Hoc is apparently considered production instead of development. I created the push production certificate, installed it and voila! It works.
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