【发布时间】:2020-03-31 13:44:40
【问题描述】:
我仅在尝试使用 UserNotifications 框架注册远程通知时收到此错误。 使用 PushKit 时一切正常。
dispatch_queue_t mainQueue = dispatch_get_main_queue();
// Create a push registry object
self.voipRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
// Set the registry's delegate to self
self.voipRegistry.delegate = self;
// Set the push type to VoIP
self.voipRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
自 Xcode 11 和 iOS13 以来,PushKit 发生了更改以支持 CallKit,因此我尝试改用 UserNotifications,如 Apple's documentation 中所述
Important
If you are unable to support CallKit in your app, you cannot use PushKit to handle push notifications. Instead, configure your app's push notification support with the UserNotifications framework.
我正在以这种方式注册远程通知
- (BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotifications];
并接收令牌:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
但是当我从我的服务器发送通知时,我得到了 DeviceTokenNotForTopic。 我不确定,如果 UserNotifications 框架使用不同的 APNs 服务器或令牌格式不同。
【问题讨论】:
标签: ios objective-c apple-push-notifications pushkit usernotifications