我正在尝试使用我自己的简单绑定(bind) PushManager 在 robovm.0.0.14 上注册推送通知,如下所示:
#import "PushManager.h"
@implementation PushManager
-(void) registerForPushNotifications
{
NSLog(@"Registering for push notifications");
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
NSLog(@"Registering for IOS 8 and later");
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
}
@end
它正在 IOS8 设备上运行,但应用程序在 IOS 7 设备上在类链接阶段崩溃,如下所示:
dyld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings
Referenced from: /var/mobile/Applications/6C45E5E5-AF8F-43E8-9680-5CD3076DB1FF/Game.app/Game Expected in: /System/Library/Frameworks/UIKit.framework/UIKit in /var/mobile/Applications/6C45E5E5-AF8F-43E8-9680-5CD3076DB1FF/Game.app/Game
我知道
UIUserNotificationSettings
类与 iOS 8 一起出现,但我如何忽略 iOS 7 上的绑定(bind) PushManager 类?是否有针对此 iOS 版本特定问题的解决方法或修复?
最佳答案
我检查类的存在UIUserNotificationSettings
,这是相关的,仅适用于 iOS 8。
NSClassFromString(@"UIUserNotificationSettings")
这有点间接,但对我有用。
关于ios - Robovm : registering for push notification on IOS7 & IOS8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25884109/