IT虾米网

iOS判断消息推送开关详解

wyy 2021年12月07日 手机开发 337 0
本文章主要介绍了iOS判断消息推送开关,具有不错的的参考价值,希望对您有所帮助,如解说有误或未考虑完全的地方,请您留言指出,谢谢!


判断消息推送开关:

    BOOL isNotifyAlert = NO, isNotifySound = NO; 
    if (IsIOS8) 
    { 
        UIUserNotificationType types = [[UIApplication sharedApplication] currentUserNotificationSettings].types; 
        isNotifyAlert = (types & UIUserNotificationTypeAlert) == UIUserNotificationTypeAlert; 
        isNotifySound = (types & UIUserNotificationTypeSound) == UIUserNotificationTypeSound; 
    } 
    else 
    { 
        UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; 
        isNotifyAlert = (types & UIRemoteNotificationTypeAlert) == UIRemoteNotificationTypeAlert; 
        isNotifySound = (types & UIRemoteNotificationTypeSound) == UIRemoteNotificationTypeSound; 
    } 
    debugLog(@"-------------推送开关, 接收:%@, 声音:%@", [NSString fromBOOL:isNotifyAlert],[NSString fromBOOL:isNotifySound] );






发布评论
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

JS贪吃蛇游戏详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。