Ios push notification not showing in app

I am trying to set up push notifications in my iOS7 application and am encountering problems.

Basically, a click never appears when I create certificates and provisioning profiles. Currently, I am only creating it for development and getting a distribution that was made when I was ready to send it. But in development setup, everything seems to be correct. I created a PHP file to create a message in a dictionary format, and I believe that everything is correct on this side. The passthru code is added correctly, and I connect to the APNS server (development side) correctly, I can say this because when I am wrong, the code of my code does not work.

Looking through the iOS development documents related to PUSH, I added persistantConnection to my profile and looked at the detailed log files, and according to this data, it should also work.

I am not completely familiar with reading this data, but the good things that I was told to look for were there, and the bad things were not.

I will attach my PHP script and log from the device

Php script

session_start(); if($_POST['message']){ $deviceToken = array(); $deviceToken[0]="xxxx3ee0 3xxxx973 6bxxxxea 2843xxxx dx5xbx1x x4x8x0xe 7xx65xx9 x61xx01x"; $payload ='{ "aps" : { "alert" : "'.$_POST['message'].'" , "badge" : 1 , "sound" : "bingbong.aiff" } }'; /* $payload = ' { "aps": { "alert": "alert", "sound": "default" }, "message": "'.$_POST['message'].'", "id": 1234 } '; */ $apnsHost = 'gateway.sandbox.push.apple.com'; $apnsPort = 2195; $apnsCert = 'ck.pem'; $streamContext = stream_context_create(); stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert); stream_context_set_option($streamContext, 'ssl', 'passphrase', "xoxoxoxo"); $apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext); if(!$apns) { print"Stream failed to create ". $error. " ".$errorString; return; } else { print"Message Sent"; } foreach($deviceToken as $key=>$value){ $apnsMessage = chr(0) . pack("n",32) . pack('H*',str_replace(' ', '', $value)) . pack ("n", strlen($payload)) . $payload; // $apnsMessage = chr(0) . chr(0) . chr(32) . @pack('H*', str_replace(' ', '', $value)) . chr(0) . chr(strlen($payload)) . $payload; fwrite($apns, $apnsMessage); print "<BR>Message Delivered - ". $payload; } fclose($apns); } ?> <form action="blanket.php" method="post"> <input type="text" placeholder="message" name="message"> <input type="submit" value="submit"> </form> 

According to the doc, this is what I'm looking for

I see it:

Look for messages from the apsd process. Ideally, you will see Connected to the courier x-courier.sandbox.push.apple.com, where x is a small integer. This indicates that the device has successfully established a permanent connection to the push service.

I do not see it:

On the other hand, you can see the disconnection in response to a connection failure. This means that persistent connection failed. In this case, the goal is to find out what is happening with your network, which leads to a connection failure. Make sure that firewalls are not blocking TCP traffic on port 5223.

I do not see it:

A set of message connections ignored by that means that the user has decided to turn off notifications for the applications listed in the message. This will be followed by a β€œSend Filter” message for allowed hashes, in which iOS actually sends allowed and ignored topics to APN.

I do not see it:

The message Failed to parse the JSON message payload, indicates that the JSON dictionary in the notification payload is not valid in JSON format.

The bad part also I do not see this:

Message A received message for an enabled partition means that the device received a notification from the push service.

DATA FROM LOG search on these criteria "Connected to Courier" showing good information

 2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16e49ff0> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference NonCellular shouldUseDualChannel YES. Connected on 1 interfaces. 2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16d78f70> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference NonCellular shouldUseDualChannel YES. Connected on 1 interfaces. 2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Connected to courier 2-courier.sandbox.push.apple.com (17.149.34.142) connection: <APSCourierConnection: 0x16d79810> onInterface: NonCellular 2014-03-14 14:56:54 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Connected to courier 30-courier.push.apple.com (17.149.36.134) connection: <APSCourierConnection: 0x16d4a380> onInterface: NonCellular 2014-03-14 14:56:55 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Calling into AWD for PushConnectionConnected 2014-03-14 14:56:55 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Calling into AWD for PushConnectionConnected 2014-03-14 14:57:52 -0700 apsd[83]: <APSCourier: 0x16d78f70> - systemDidLock and we're connected via noncellular, sending inactive ping to the server 2014-03-14 14:57:52 -0700 apsd[83]: <APSCourier: 0x16e49ff0> - systemDidLock and we're connected via noncellular, sending inactive ping to the server 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourierConnection: 0x16d4a380> WWAN is connected; to be consistent, closing the non-cellular connection 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> courierConnection <APSCourierConnection: 0x16d4a380> asked us to disconnect stream on interface NonCellular. Connected on 2 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Calling into AWD for ConnectionDisconnected 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> courierConnection <APSCourierConnection: 0x16d4a380> asked us to disconnect stream on interface NonCellular. Connected on 1 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0>: Calling into AWD for ConnectionDisconnected 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference None shouldUseDualChannel NO. Connected on 1 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16e49ff0> _connectStream - caller is ensuring that we are connected. We are so there nothing to do here. - Connected on 1 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourierConnection: 0x16d79810> WWAN is connected; to be consistent, closing the non-cellular connection 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> courierConnection <APSCourierConnection: 0x16d79810> asked us to disconnect stream on interface NonCellular. Connected on 2 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Calling into AWD for ConnectionDisconnected 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> courierConnection <APSCourierConnection: 0x16d79810> asked us to disconnect stream on interface NonCellular. Connected on 1 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70>: Calling into AWD for ConnectionDisconnected 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> attempting to _connectStream. currently onInterface WWAN consecutiveFailures 0 preference None shouldUseDualChannel NO. Connected on 1 interfaces. 2014-03-14 14:57:57 -0700 apsd[83]: <APSCourier: 0x16d78f70> _connectStream - caller is ensuring that we are connected. We are so there nothing to do here. - Connected on 1 interfaces. 

As far as I can tell, it should work, but it is not.

Any ideas?

+6
source share
1 answer

Can you try to remove the empty space between the device token so that your device token looks like

 $deviceToken[0]="xxxx3ee03xxxx9736bxxxxea2843xxxxdx5xbx1xx4x8x0xe7xx65xx9x61xx01x"; 

According to my knowledge, the device token should not contain any space and the characters <,>

Also check the return code from the request and feedback service to inform you of the unsuccessful push notifications mentioned here

Please let me know if it works.

+1
source

All Articles