我正尝试使用示例代码和https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/6.3/notifications/push-notifications-native-ios-applications/提供的步骤通过Worklight在iOS设备上发送推送通知
当我在iOS 7设备上运行应用程序时,我得到一个设备令牌,因此当我点击订阅按钮时,我得到一个成功的响应。即使我们没有在didFinishLaunchingWithOptions中编写任何用于注册ForRemoteNotifications的代码,这也行得正常。
但是当我在iOS 8和iOS 9设备上运行相同的代码时,我在控制台上收到以下消息:
iOSNativePush [1119:372642] registerForRemoteNotificationTypes:iOS 8.0及更高版本不支持。
为了让我的应用程序在iOS> = 8设备上运行,我编写了以下代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound)];
}
return YES;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[application registerForRemoteNotifications];
}
我仍然得到" iOSNativePush [1119:372642] registerForRemoteNotificationTypes:iOS 8.0及更高版本不支持"控制台中的消息,但对于 iOS 8 设备我收到设备令牌,设备正在订阅,但同样的事情不适用于 iOS 9 设备。
请帮我获取iOS 9设备的设备令牌。
答案 0 :(得分:4)
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
使用上面的代码
答案 1 :(得分:0)
此问题已在MobileFirst 6.3及更高版本的后续iFix中得到修复。
要解决:
1)将您的MobileFirst工作室更新为最新的iFix。
2)添加新的iOS原生环境。
3)用新生成的文件夹替换样本的原生文件夹(使用iFix)
4)清理,构建和部署。