IT虾米网

iOS判断消息推送开关

wyy 2021年12月07日 手机开发 553 0


判断消息推送开关:

    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贪吃蛇游戏