简体   繁体   English

没有为 iOS 13 调用 didRegisterForRemoteNotificationsWithDeviceToken(目标 C)

[英]didRegisterForRemoteNotificationsWithDeviceToken not called for iOS 13 (Objective C)

I am using below code to register for push notification alert.我正在使用以下代码注册推送通知警报。

UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
NSLog(@"fapa=1");
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
    NSLog(@"fapa=error==%@", error);
    if(!error){
        NSLog(@"fapa=registering now");
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"fapa=registering now 2");
             [[UIApplication sharedApplication] registerForRemoteNotifications];
        });
    }
}];

Below is the place where I get token下面是我获得令牌的地方

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

However problem is this method is not called from iOS 13 (not sure whether for just iOS 13.4.1 or all iOS 13).然而问题是这个方法不是从 iOS 13 调用的(不确定是仅适用于 iOS 13.4.1 还是所有 iOS 13)。

Is anyone have idea why this is happening or Apple update something or this is a bug?有谁知道为什么会发生这种情况或Apple更新某些东西或这是一个错误?


Sorry for adding Swift tag, but just I add as mostly many developers filter SO with Swift questions only (even they know Objective C. So just to bring in attention, I add swift too. Sorry for adding Swift tag, but just I add as mostly many developers filter SO with Swift questions only (even they know Objective C. So just to bring in attention, I add swift too.


Edit 1编辑 1

Something weird.有什么奇怪的。

From WIFI when I connect to mobile network, I got token & didRegisterForRemoteNotificationsWithDeviceToken start working.当我从 WIFI 连接到移动网络时,我得到了令牌和 didRegisterForRemoteNotificationsWithDeviceToken 开始工作。

Now when I go back to WIFI again didRegisterForRemoteNotificationsWithDeviceToken start working.现在,当我 go 再次回到 WIFI 时,didRegisterForRemoteNotificationsWithDeviceToken 开始工作。

What is this?这是什么? Did anyone face this weird issue?有人遇到过这个奇怪的问题吗?


Edit 2编辑 2

What I did is I put above code (of registering for push notification) in one function and call that function every 5 seconds.我所做的是将上述代码(用于注册推送通知)放在一个 function 中,并每 5 秒调用一次 function。 Surprisingly, I get token now, but token for iOS 13 onwards, token is not as I get before.令人惊讶的是,我现在得到了令牌,但是 iOS 13 以后的令牌,令牌不像我以前那样。 I need to check further on this issue.我需要进一步检查这个问题。 Once I check, I will post an answer for this question.一旦我检查,我将发布这个问题的答案。

But calling register push function every 5 seconds did the trick.但是每 5 秒调用一次 register push function 就可以了。

What I did is I put above code (of registering for push notification) in one function and call that function every 5 seconds.我所做的是将上述代码(用于注册推送通知)放在一个 function 中,并每 5 秒调用一次 function。 Surprisingly, I get token now, but token for iOS 13 onwards, token is not as I get before.令人惊讶的是,我现在得到了令牌,但是 iOS 13 以后的令牌,令牌不像我以前那样。 I need to check further on this issue.我需要进一步检查这个问题。 Once I check, I will post an answer for this question.一旦我检查,我将发布这个问题的答案。

But calling register push function every 5 seconds did the trick.但是每 5 秒调用一次 register push function 就可以了。

I am putting this answer as no one will understand Edit 1 I have above is the answer.我提出这个答案是因为没有人会理解我上面的编辑 1 就是答案。 Better to have an answer for the question.最好有问题的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IOS 13 APNS didRegisterForRemoteNotificationsWithDeviceToken 未调用 - IOS 13 APNS didRegisterForRemoteNotificationsWithDeviceToken not called iOS 13.x didRegisterForRemoteNotificationsWithDeviceToken 从未被调用 - iOS 13.x didRegisterForRemoteNotificationsWithDeviceToken is never called 在ios 9中没有调用didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios 9 iOS 11 didRegisterForRemoteNotificationsWithDeviceToken未调用 - IOS 11 didRegisterForRemoteNotificationsWithDeviceToken not called 在iOS7上没有调用didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken not called on iOS7 didRegisterForRemoteNotificationsWithDeviceToken 未在 ios 10 上调用 - didRegisterForRemoteNotificationsWithDeviceToken not getting called on ios 10 应用程序:didRegisterForRemoteNotificationsWithDeviceToken:未称为ios 10.3.2 - application:didRegisterForRemoteNotificationsWithDeviceToken: not called ios 10.3.2 在iOS 8中未调出didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios8 没有使用简单的 iOS 应用程序调用 didRegisterForRemoteNotificationsWithDeviceToken - didRegisterForRemoteNotificationsWithDeviceToken not called with simple iOS app didRegisterForRemoteNotificationsWithDeviceToken 未在 ios8 中调用,但 didRegister...Settings 是 - didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister…Settings is
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM