ios - 接收重复的推送通知 ios9

标签 ios objective-c iphone apple-push-notifications

我在 iOS9 中两次收到相同的推送通知,尽管它在 iOS8 中工作正常。

我已使用以下代码注册推送通知:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
    // use registerUserNotificationSettings
    UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:( UIUserNotificationTypeSound | UIUserNotificationTypeAlert|UIUserNotificationTypeBadge) categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:setting];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    // use registerForRemoteNotifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert |UIRemoteNotificationTypeBadge)];
}

#else

// use registerForRemoteNotifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

#endif

最佳答案

我在几个应用程序中遇到过这个问题,如果您调用 registerUserNotificationSettings: 超过 1 次,看起来会出现重复项。

此答案中的更多详细信息: https://stackoverflow.com/a/35064911/4495995

关于ios - 接收重复的推送通知 ios9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32840916/

相关文章:

c++ - 来自 Grand Central Dispatch 的 dispatch_async() 和来自 C++11 的 std::async

iphone - 对二维数组进行排序

iphone - ios voip 应用程序在后台仅运行 10 分钟

objective-c - 由于UIWebView,Apple拒绝了 objective-c AFNetworking

jquery - 如何让 JQuery Carousel 在 iPhone 中工作?

iphone - 我的 Apple Dev 帐户即将过期。我的配置文件是否仍允许我在 iOS 设备上测试我的应用程序?

ios - WatchOS 2 - iOS UserDefaults 共享

ios - 部署到 Apple 商务管理客户

iphone - 自定义导航 Controller 工具栏比 iPhone 底部高一个像素

ios - 日期格式化程序在转换为字符串 Objective-C 时给出错误的日期