zoukankan      html  css  js  c++  java
  • 极光推送 JPush 项目简单使用

    打开或者关闭推送

    - (void)pushSwitch:(UISwitch *)sender {
        if (sender.on) {
            [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"JPushState"];
            [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                           UIRemoteNotificationTypeSound |
                                                           UIRemoteNotificationTypeAlert)
                                               categories:nil];
        }
        else {
            [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"JPushState"];
            [[UIApplication sharedApplication] unregisterForRemoteNotifications];
        }
    }
    

      

    AppDelegate文件中

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"JPushState"] isEqualToString:@"1"]) {
            [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                           UIRemoteNotificationTypeSound |
                                                           UIRemoteNotificationTypeAlert)
                                               categories:nil];
            [APService setupWithOption:launchOptions];
        }
    
    }
    

      

    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        [APService registerDeviceToken:deviceToken];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
        [APService handleRemoteNotification:userInfo];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
        [APService handleRemoteNotification:userInfo];
        completionHandler(UIBackgroundFetchResultNewData);
    }
    

      

  • 相关阅读:
    showModalDialog 超过问题
    工作流,WEB框架,UI组件网络收集整理
    VSS使用方法详解
    Windows远程桌面连接命令mstsc
    Nginx 配置简述
    jQuery编程代码规范的最佳实践
    TinyMCE(富文本编辑器)在Asp.Net中的使用方法
    扣文转文方法
    VS2013 EMMET插件学习
    为革命保护视力 --- 给 Visual Studio 换颜色
  • 原文地址:https://www.cnblogs.com/songxing10000/p/5072821.html
Copyright © 2011-2022 走看看