Apple Push Notification Issue: Having Trouble Decrypting Messages

I have multiple mobile applications, one developed in React Native and the other in Objective-C and Swift hybrid technology. I use my own system to send push notifications, and these notifications are left encrypted in the Apple queues. However, in any of my applications, I am unable to catch these messages in the code block where I decrypt them. As a result, users see the messages encrypted. While I can deterministically detect this issue on devices experiencing the offload feature from Apple, I've also noticed sporadic occurrences of this issue on devices not utilizing offload. Due to my security policies, I have no chance of sending messages unencrypted. I'm trying to understand why this is happening and need suggestions for a solution. Is there anyone who can help?

Additional Information:

  • I use my own system for push notifications.
  • Messages are left encrypted in the Apple queues.
  • I am unable to catch the messages in the code block where I decrypt them in one of the applications.
  • I can deterministically detect the issue on devices experiencing the offload feature.
  • I've noticed sporadic occurrences of this issue on devices not using offload.
  • Due to security policies, I have no chance of sending messages unencrypted.

I tried sending without offloading, and the messages arrived unencrypted I searched for a callback handler function on the Apple side - couldn't find one. To ensure notifications were sent correctly, I performed token checks in my database.

It is not clear from your message whether this is a sporadic issue ("I've noticed sporadic occurrences") or you weren't able to find out how this is done at all ("I searched for a callback handler function on the Apple side").

The last possibility I can guess is that you are using a 3rd party tool or library that is handling the notifications for you, and that is failing sporadically.

In any case, decrypting of encrypted notifications is usually done using a Notification Service Extension (https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension). If you are looking for a callback handler to process your notifications, that is what you need to implement.

If you are already using a NSE, then the sporadic failures would be explained by the failure to launch the extension, or the extension code failing, and perhaps crashing due to various reasons. To quickly touch a few common issues:

  • there is currently a known issue with extensions launching after an app update, which is resolved by rebooting the device
  • common issues with extensions after launch are: crashing for various issues, being terminated by the system for taking too long ( > 30 seconds), or using more than allowed memory (24 MB)

Console logs and various debugging techniques should help you find the cause.

Apple Push Notification Issue: Having Trouble Decrypting Messages
 
 
Q