zoukankan      html  css  js  c++  java
  • iOS应用内跳转系统推送设置页

    #pragma mark - 是否开启APP推送
    /**是否开启推送*/
    - (BOOL)isSwitchAppNotification {
        if ([UIDevice currentDevice].systemVersion.doubleValue >= 10.0) {
            __block BOOL result = NO;
            //异步线程中操作是否完成
            __block BOOL inThreadOperationComplete = NO;
            [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
                if (settings.authorizationStatus == UNAuthorizationStatusDenied) {
                    result = NO;
                }else if (settings.authorizationStatus == UNAuthorizationStatusNotDetermined) {
                    result = NO;
                }else if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
                    result = YES;
                }else {
                    result = NO;
                }
                inThreadOperationComplete = YES;
            }];
            
            while (!inThreadOperationComplete) {
                [NSThread sleepForTimeInterval:0];
            }
            return result;
        }
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wdeprecated-declarations"
        else if ([UIDevice currentDevice].systemVersion.doubleValue >= 8.0)
        {
            UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
            if (UIUserNotificationTypeNone != setting.types) {
                return YES;
            }else {
                return NO;
            }
            
        }else
        {
            UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
            if(UIRemoteNotificationTypeNone != type) {
                return YES;
            }else {
                return NO;
            }
        }
    }
    /// 进入前台监听
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        self.navigationItem.title = @"通知管理";
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
        [self setupMainUI];
        self.swt.on = [self isSwitchAppNotification];
    }
    
    
    #pragma mark - NSNotification
    - (void)appBecomeActive:(NSNotification *)note {
        self.swt.on = [self isSwitchAppNotification];
    }

    参考

    https://www.jianshu.com/p/16d2cdefb9cd

  • 相关阅读:
    读写锁操作(ReaderWriterLockSlim)
    VirtualBox的小秘密:命令行
    云的始祖概念,认识Linux瘦客户机
    Flash ActionScript 3.0 通过asp.net 访问 数据库
    js刷新iframe框架的几种情况分析
    Mozilla两款火狐插件包含恶意代码被紧急喊停
    asp.net中DataBinder.Eval的用法总结
    实现firebird的Embedded模式(.net 3.5)
    Flash Player 9 支持H.264视频和aac音频(附官方代码)
    右下角浮动广告代码DEMO
  • 原文地址:https://www.cnblogs.com/qingzZ/p/15309102.html
Copyright © 2011-2022 走看看