swift中友盟推送

swift中友盟推送,第1张

概述在oc中的一段话: #if __IPHONE_OS_VERSION_MAX_ALLOWED >= _IPHONE80_ if(UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { //register remoteNotification types UIMutableUserNotificatio

在oc中的一段话:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= _IPHONE80_    if(UMSYstem_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))    {        //register remoteNotification types        UIMutableUserNotificationAction *action1 = [[UIMutableUserNotificationAction alloc] init];        action1.IDentifIEr = @"action1_IDentifIEr";        action1.Title=@"Accept";        action1.activationMode = UIUserNotificationActivationModeForeground;//当点击的时候启动程序                UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init];  //第二按钮        action2.IDentifIEr = @"action2_IDentifIEr";        action2.Title=@"Reject";        action2.activationMode = UIUserNotificationActivationModeBackground;//当点击的时候不启动程序,在后台处理        action2.authenticationrequired = YES;//需要解锁才能处理,如果action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;        action2.destructive = YES;                UIMutableUserNotificationcategory *categorys = [[UIMutableUserNotificationcategory alloc] init];        categorys.IDentifIEr = @"category1";//这组动作的唯一标示        [categorys setActions:@[action1,action2] forContext:(UIUserNotificationActionContextDefault)];                UIUserNotificationSettings *userSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert                                                                                     categorIEs:[NSSet setWithObject:categorys]];        [UMessage registerRemoteNotificationAndUserNotificationSettings:userSettings];            } else{        //register remoteNotification types        [UMessage registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge         |UIRemoteNotificationTypeSound         |UIRemoteNotificationTypeAlert];    }#else        //register remoteNotification types    [UMessage registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge     |UIRemoteNotificationTypeSound     |UIRemoteNotificationTypeAlert];    #endif

然后翻译成swift为:
if (UIDevice.currentDevice().systemVersion.compare("8.0.0") == .OrderedSame || UIDevice.currentDevice().systemVersion.compare("8.0.0") == .OrderedDescending){            let action1 = UIMutableUserNotificationAction();            action1.IDentifIEr = "action1_IDentifIEr"            action1.Title = "Accept"            action1.activationMode = UIUserNotificationActivationMode.Foreground//当点击的时候启动程序                        let action2 = UIMutableUserNotificationAction();//第二按钮            action2.IDentifIEr = "action2_IDentifIEr"            action2.Title = "Reject"            action2.activationMode = UIUserNotificationActivationMode.Background            action2.authenticationrequired = true            action2.destructive = true                        let categorys = UIMutableUserNotificationcategory();            categorys.IDentifIEr = "category1";//这组动作的唯一标示            categorys.setActions([action1,action2],forContext: UIUserNotificationActionContext.Default)                                    let userSettings = UIUserNotificationSettings(forTypes:[                .Badge,.sound,.Alert],categorIEs: Set(arrayliteral: categorys))                        UMessage.registerRemoteNotificationAndUserNotificationSettings(userSettings)        } else {            UMessage.registerForRemoteNotificationTypes([.Badge,.Alert])        }
总结

以上是内存溢出为你收集整理的swift中友盟推送全部内容,希望文章能够帮你解决swift中友盟推送所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1082563.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存