I'm encountering an issue with our legacy Objective-C codebase that uses UIApplicationDelegate.
Here are the steps to reproduce the issue:
- Uninstall the application from the device.
- Install and launch the application.
- As part of the launch event, the client requests notification permission.
- The permission prompt is still displayed, even though the client receives a remote notification token (which appears to be a cached one).
I followed the same steps with a sample app built with Swift (SwiftUI), and this issue did not occur. In the Swift app, I consistently received a delegate<didRegisterForRemoteNotificationsWithDeviceToken> call after the user allowed the notification permission.
Could you please provide some insights into why this might be happening with only our client?
Notification permission and token delivery are not tied together. You can indeed even get a token without getting the authorization (albeit not being of much use as the notifications won't be shown).
I suspect this is due to a changed timing that causes the delegate call to be faster. If this is a problem, you can wait until you have authorization to make the register call.
I theorized that the call you receive could be due to a cached token IF you have not been calling register at that point. As you say you have already called it at that point, there is no reason to presume you will get a second call.