gpt4 book ai didi

iOS 推送通知适用于 iOS 8 但不适用于 iOS SDK 8.1 中的 iOS 7

转载 作者:行者123 更新时间:2023-11-29 12:34:24 25 4
gpt4 key购买 nike

if([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { 

[self registerForiOS8PushSettings]; //for iOS8

} else {
//iOS7 or earlier

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

}

无法获取到 iOS7 设备的推送通知。 didRegisterForRemoteNotificatiosnWithDeviceToken 被调用,实际上消息已成功传递。在 iOS8 中运行良好。

最佳答案

在 iOS8 中,流程发生了变化。要让您的应用注册 iOS8 和早期版本,请执行以下操作:

-(void)registerAppForNotifications{

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeNewsstandContentAvailability| UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}

}

关于iOS 推送通知适用于 iOS 8 但不适用于 iOS SDK 8.1 中的 iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26755530/

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