ios - Robovm : registering for push notification on IOS7 & IOS8

标签 ios apple-push-notifications robovm

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

相关文章:

ios - 在 NSDictionary 中设置值时,此类不符合键值编码

iphone - 应用程序关闭时更新徽章图标

swift - UIImage 的 UNNotificationAttachment 超出内存

android - Gradle 卡在执行任务 : [:android:generateDebugSources

java - 使用 gradle libgdx 项目生成 IPA

java - 编写RoboVM绑定(bind)

ios DemoCast 播放器 Chromecast "does not support app"

ios - UIInteractiveTransition 并使过渡再次成为交互式

ios - 如何提高 drawRect 性能以将不同的 UIImages 合并在一起?

objective-c - 收到推送通知时如何调用函数?