gpt4 book ai didi

objective-c - isRegisteredForRemoteNotifications 总是返回 no

转载 作者:太空狗 更新时间:2023-10-30 03:41:15 24 4
gpt4 key购买 nike

我收到了弹出窗口,我已经接受了,我在通知中看到它并且它已打开但是这段代码总是返回否,我似乎无法找出原因

UIApplication *application = [UIApplication sharedApplication];

BOOL enabled;

// Try to use the newer isRegisteredForRemoteNotifications otherwise use the enabledRemoteNotificationTypes.
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{

enabled = [application isRegisteredForRemoteNotifications];
}
else
{
UIRemoteNotificationType types = [application enabledRemoteNotificationTypes];
enabled = types & UIRemoteNotificationTypeAlert;

}
if (enabled){
NSLog(@"is registered");
}else{
NSLog(@"is not registered");
}

最佳答案

我认为它发生的原因可能是:

  1. isRegisteredForRemoteNotifications 将始终返回 NO模拟器。
  2. registerForRemoteNotifications 失败。

关于objective-c - isRegisteredForRemoteNotifications 总是返回 no,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28242332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com