didRegisterForRemoteNotificationsWithDeviceToken called twice?

didregisterforremotenotificationswithdevicetoken not called
didregisterforremotenotificationswithdevicetoken not called swift 5
didregisterforremotenotificationswithdevicetoken swift
didregisterforremotenotificationswithdevicetoken not called firebase
didregisterforremotenotificationswithdevicetoken ios 13
didregisterforremotenotificationswithdevicetoken ios swift
didregisterforremotenotificationswithdevicetoken not called ios 13 objective c

Somewhat similar to When is didRegisterForRemoteNotificationsWithDeviceToken called?.

When the user first installed the app and it prompts whether to accept notification, will didRegisterForRemoteNotificationsWithDeviceToken be called if the user accepts it?

I'm currently calling registerForRemoteNotificationTypes after the user successfully signs in or creates an account.

In subsequently launches, the didRegisterForRemoteNotificationsWithDeviceToken delegate is called even without calling registerForRemoteNotificationTypes in AppDelegate.

If I follow the docs and example code:

By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device.

- (void)applicationDidFinishLaunching:(UIApplication *)app {

   // other setup tasks here....
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:...

But by requesting the token when the app launches, the delegate will be called twice.

A couple of questions and clarity needed:

  1. For the initial prompt to happen, a call for registerForRemoteNotificationTypes must be made for the prompt to appear? But, the delegate will be called twice if I call this manually in AppDelegate. Is it suppose be that way?

  2. If the user accepts the initial prompt, will didRegisterForRemoteNotificationsWithDeviceToken be called automatically? Or must we invoke registerForRemoteNotificationTypes in AppDelegate? But then the delegate will be called twice for future launches?

  3. If the user denies and later accept it via Setting, what happens?


0. For the initial prompt to happen, a call for registerForRemoteNotificationTypes must be made for the prompt to appear? But, the delegate will be called twice if I call this manually in AppDelegate. Is it suppose be that way? This isn't true. Found out that there were actually 2 registerForRemoteNotiicationTypes being made in AppDelegate.

If the user accepts the initial prompt, will didRegisterForRemoteNotificationsWithDeviceToken be called automatically? No, Your remote notification registration process starts when 'allow access' is clicked, but didRegisterForRemoteNotificationsWithDeviceToken method is called only on successful APNS registration.

If your application has previously registered, calling registerForRemoteNotificationTypes: results in the operating system passing the device token to the delegate immediately without incurring additional overhead

You can determine whether an application is launched as a result of the user tapping the action button or whether the notification was delivered to the already-running application by examining the application state. In the delegate’s implementation of the application:didReceiveRemoteNotification: or application:didReceiveLocalNotification: method, get the value of the applicationState property and evaluate it. If the value is UIApplicationStateInactive, the user tapped the action button; if the value is UIApplicationStateActive, the application was frontmost when it received the notification.

application:didRegisterForRemoteNotificationsWithDeviceToken , If the device token hasn't changed, registering with APNs and returning the token happens quickly. Typically, this method is called only after you call the� I am making an application in which I want to implement apple push notification service. I am following the step-by-step instructions given in this tutorial. But still, the methods are not calle

Nope. this method only called once when app launch . if it is called twice then it will be called from your code. Try to see that if you are putting code like

[application registerUserNotificationSettings:mySettings];
[application registerForRemoteNotifications];

in didFinishLaunchingWithOptions

then in go to

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings

is that you might be calling [application registerForRemoteNotifications];

so remove this code.

didRegisterForRemoteNotificationsWithDeviceToken loops infinitely , Also, [[PushNotificationManager pushManager] registerForPushNotifications] is definitely only called once, at least from my code. Typically, this method is called only after you call the register For Remote Notifications() method of UIApplication, but UIKit might call it in other rare circumstances. For example, UIKit calls the method when the user launches an app after having restored a device from data that is not the device’s backup data.

Check the Application State inside the function didReceiveRegistrationToken

let state = UIApplication.shared.applicationState
        if state == .background || state == .inactive {
        } else if state == .active {

Registering Push Notifications Twice � Issue #3288 � facebook/react , I'm running iOS 8+ I'm seeing the push registration callback twice. didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; PushNotificationIOS addEventListener called twice for register event #5500. Closed. This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site.

ios, for initial prompt happen, call registerforremotenotificationtypes must made prompt appear? but, delegate called twice if call manually in� When we run the example above, and the url is cached, the callback is actually called twice! It's easy to think of calling the callback as a kind of asynchronous return statement. But execution continues after it, and the HTTP request to fetch example.js happens as if the file wasn't in the cache.

didReceiveRemoteNotification called twice, didregisterforremotenotificationswithdevicetoken called multiple times. I have implemented Push Notification in my App. When my app is in the foreground then � The code I have written is working since days and now today suddenly, it's not working (without any code change). didRegisterForRemoteNotificationsWithDeviceToken is

Setting up push notifications. Everything works but the flow is very , For my iOS 9 devices, didRegisterForRemoteNotificationsWithDeviceToken is called first, and then didRegisterUserNotificationSettings is called once the user� A common pitfall when using the Web service data control - it gets executed twice if the return of the method is a collection.

  • Ok. It will be called only if the user accepts the prompt and a successful registration? Otherwise the failure method will be called? What happens if the user declines the prompt, will the error method be called?
  • If the user decline the prompt, he has not initiated the APNS registration process & the error method will never be called. didFailToRegisterForRemoteNotificationsWithError method is called only on registration failure.