未在 ios 13 上获取 APNS 设备令牌 [英] Not getting APNS Device token on ios 13

查看:29
本文介绍了未在 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 设备令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆