2

我正在尝试使用我自己的简单绑定 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:找不到符号:_OBJC_CLASS_$_UIUserNotificationSettings
引用自:/var/mobile/Applications/6C45E5E5-AF8F-43E8-9680-5CD3076DB1FF/Game.app/Game 预期在:/System/Library/Frameworks/UIKit.framework/UIKit 中/var/mobile/Applications/6C45E5E5-AF8F-43E8-9680-5CD3076DB1FF/Game.app/Game

我知道UIUserNotificationSettingsiOS 8 即将推出课程,但如何忽略 iOS 7 上的绑定 PushManager 课程?

是否有针对此 iOS 版本特定问题的解决方法或修复?

4

1 回答 1

0

我检查了 class 的存在UIUserNotificationSettings,这是相关的,并且仅适用于 iOS 8。

NSClassFromString(@"UIUserNotificationSettings")

这有点间接,但对我有用。

于 2014-12-28T23:22:07.520 回答