Robovm:在IOS7和&amp ;;上注册推送通知iOS8上

时间:2014-09-17 06:53:47

标签: ios apple-push-notifications robovm

我正在尝试使用我自己的简单绑定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

我知道{8}会出现UIUserNotificationSettings类,但是如何在iOS 7上忽略绑定的PushManager类?

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

1 个答案:

答案 0 :(得分:0)

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

NSClassFromString(@"UIUserNotificationSettings")

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