Debug Failed Push Messages By Logging APSD Process

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 and when running your app look for lines in the console output 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:

unknown apsd[2] : : Connecting to courier 40-courier.push.apple.com.
unknown apsd[56] : : Received connected response OK
unknown apsd[56] : : Received message size 4096

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:

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

Successful push messages will look as follows:

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

Additional Reading

You’ll find many additional tips and tricks in the Apple Technical Note on Troubleshooting Push Messages.