13上未获取APNS设备令牌

13上未获取APNS设备令牌

本文介绍了在iOS 13上未获取APNS设备令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与APNS设备令牌有关的问题.在我使用Xcode 10.2和iOS 12.1之前.这时我曾经在委托方法中获取设备令牌

I have issue related to APNS device token . Before I was using Xcode 10.2 and iOS 12.1. At this moment I used to get the device token in delegate method

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

我正在这样注册APNS,并且运行正常.

I am registering for APNS like this and it was working fine.

UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
                if(!error){
                    [[UIApplication sharedApplication] registerForRemoteNotifications];
                }
    }];

现在,当将iOS 13安装到我的iPhone设备上并使用Xcode 11时,不会调用委托方法didRegisterForRemoteNotificationsWithDeviceToken.无法理解此问题.我已经对此进行了研究,我知道从委托方法获取令牌有一些变化,但是在我的情况下,甚至没有调用委托方法.再次适用于iOS 12.

Now when installed iOS 13 to my iPhone device and using Xcode 11 , the delegate method didRegisterForRemoteNotificationsWithDeviceToken is not called. Unable to understand this problem .I have already done research over this , I know there are some changes in getting token from the delegate method but in my case delegate method is not even called. Again it's working fine for iOS 12.

推荐答案

只需重新启动iPhone.就这么简单,在90%的情况下,它将解决您的问题.

Just reboot your iPhone. It's as simple as that and in 90% of cases it will solve your problem.

这篇关于在iOS 13上未获取APNS设备令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:16