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);
    }
    

      

  • 相关阅读:
    qmake Manual (EN) 1
    {转}linux gcc gdb使用
    qmake 简介
    {转}linux makefile 详细教程
    {转}Linux下C开发之——gcc,gdb的使用
    关于“做一个聊天+信息分享客户端”的设想(SNS?)
    {转}算法的力量
    hdu 2047 简单递推公式
    RONOJ 6 金明的预算方案
    hdu 2446 二分搜索解题报告
  • 原文地址:https://www.cnblogs.com/songxing10000/p/5072821.html
Copyright © 2011-2022 走看看