Problem with PushNotification if you selected No for the first time

As I said in the header of this thread, I had a problem with a push notification about my application. There are 2 cases: When the application asks you if you want to click a notification and you click OK, it works fine.

This function:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken

called when registerForRemoteNotificationTypes is called:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Add registration for remote notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
    ...
}

But when you select NO at the beginning, and then you change your settings to accept a push notification, do not add anything and this function didRegisterForRemoteNotificationsWithDeviceToken is never called.

Please help me, I'm losing my mind!

+3
source share
1 answer

I see that you are registering for remote notifications at:

- (void)applicationDidFinishLaunching:(UIApplication *)application

iOS- , .

, - . Push- - .

, , - . Push- - , .

:

- (void) applicationDidBecomeActive:(UIApplication *)application

Push- , :

- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types

, " " Info.plist (UIApplicationExitsOnSuspend).

+1

Source: https://habr.com/ru/post/1758091/


All Articles