Troubleshoot Push Messages By Logging APSD Process

December 4, 2012

When things are not working as expected with push messages, having insight into what is happening at a deeper level than your code, can be very helpful. iOS offer offers a logging feature that captures APSD process information on the device.

To enable logging of push messages install the configuration profile PersistentConnectionLogging.mobileconfig on your device:

Option #1 – Upload the file to a web-server and point Safari on your phone to the file

Option #2 – Send the file via email and open the attachment

With either option you will receive an alert asking if you are good with installing APS/PC Logging.

Reboot your device. Now, exercise your app and view messages in the console. Look for lines that contain information from the apsd process

Ideally you will see messages that look as follows, indicating success creating a persistent connection to Apple push service:

Dec 03 01:15:23 unknown apsd[2] : : Connecting to courier 40-courier.push.apple.com.
Dec 03 01:22:14 unknown apsd[56] : : Received connected response OK
Dec 03 01:22:14 unknown apsd[56] : : Received message size 4096

Dec 03 01:33:54 unknown apsd[56] : : Received successful keep-alive response

If you see errors similar to those below there may be a connection issue, anything from no cellular or WiFi coverage to a problem with the TCP connection to Apple:

Dec 03 02:23:41 unknown apsd[56] : : Stream error occurred for
: Error Domain=NSPOSIXErrorDomain Code=60 “The operation couldnt be completed.
Operation timed out” UserInfo=0x25ae40 {}
Dec 03 02:23:41 unknown apsd[56] : : Disconnected in response to
connection failure. (Consecutive failures: 1)

Successful push messages will look as follows:

Dec 03 10:31:32 unknown apsd[56] : : Received message for
enabled topic ‘com.YOURPROFILE.AppName’ with payload ‘{
aps = {
alert = “Show a message here…”;
};
}’

An alternative way to view the logs is to sync your device after running your application. The log file will be saved in this location:

~/Library/Logs/CrashReporter/MobileDevice//PersistentConnection