如何使用enabledRemoteNotificationTypes,因为它是&QUOT更新code;在iOS的8英寸;?不支持 [英] How to update code using enabledRemoteNotificationTypes because it is "not supported in iOS 8"?

查看:239
本文介绍了如何使用enabledRemoteNotificationTypes,因为它是&QUOT更新code;在iOS的8英寸;?不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是code I用于RemoteNotificationType:

this is the code i used for the RemoteNotificationType:

NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

我得到的错误是这样的:

The error i got was this:

2014年9月29日15:46:47.416假人[258:21766]。enabledRemoteNotificationTypes未在iOS中支持8.0及更高版本。

2014-09-29 15:46:47.416 Dummy[258:21766] enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.

将是一个很大的帮助,如果有人能给我一个解决方案。

Would be a great help if someone could give me the solution.

推荐答案

您也可以使用此code:

You can also use this code:

if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]) {

    UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];

    if (types == UIUserNotificationTypeNone) {
        // Do something
    }

} else {

    UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

    if (types == UIRemoteNotificationTypeNone) {
        // Do something
    }
}

或者这一个,如果你只是想检查用户注册了远程通知:

Or this one if you only want to check the user is registered for remote notifications:

if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {

    BOOL isRegisteredForRemoteNotifications = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];

    if (isRegisteredForRemoteNotifications) { 
        // Do something
    }

} else {

    UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

    if (types == UIRemoteNotificationTypeNone) {
        // Do something
    }
}

这篇关于如何使用enabledRemoteNotificationTypes,因为它是&QUOT更新code;在iOS的8英寸;?不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆