zoukankan      html  css  js  c++  java
  • iOS 极光推送

    使用极光推送须要去AppleDevelope中下载证书
    这里写图片描写叙述

    当中极光推送须要的证书是.p12证书,齿轮状的证书数手机证书

    下载完证书须要配置项目project
    首先须要导入从官方下载的SDK中的lib目录中的文件
    这里写图片描写叙述
    然后再去载入须要的框架
    这里写图片描写叙述
    还须要加入一个.plist文件
    这里写图片描写叙述
    当中APP_KEY是极光推送的key

    上面设置完。又在极光站点注冊完那就须要在AppleDelegate.h代理文件里填写内容了

    #import "AppDelegate.h"
    #import "JPUSHService.h"
    #import "RootController.h"
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.window.backgroundColor = [UIColor whiteColor];
        RootController *root = [[RootController alloc]init];
        self.window.rootViewController = root;
        [self.window makeKeyAndVisible];
    
        // Required
        if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
            //能够加入自己定义categories
            [JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
                                                              UIUserNotificationTypeSound |
                                                              UIUserNotificationTypeAlert)
                                                  categories:nil];
        } else {
            //categories 必须为nil
            [JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                                              UIRemoteNotificationTypeSound |
                                                              UIRemoteNotificationTypeAlert)
                                                  categories:nil];
        }
    
        // Required
        //如需兼容旧版本号的方式。请依然使用[JPUSHService setupWithOption:launchOptions]方式初始化和同一时候使用pushConfig.plist文件声明appKey等配置内容。
        // [JPUSHService setupWithOption:launchOptions];
        [JPUSHService setupWithOption:launchOptions appKey:appKey channel:channel apsForProduction:isProduction];
        return YES;
    }
    
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
        // Required
        [JPUSHService registerDeviceToken:deviceToken];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    
        // Required,For systems with less than or equal to iOS6
        [JPUSHService handleRemoteNotification:userInfo];
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    
        // IOS 7 Support Required
        [JPUSHService handleRemoteNotification:userInfo];
        completionHandler(UIBackgroundFetchResultNewData);
    }
    
    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    
        //Optional
        NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
    }
    
    @end
    

    还须要结合极光官方文档———— 最重要的还是证书

  • 相关阅读:
    常用数据验证
    js regx验证==== 正则
    sql单列合并
    msdn的网址 sql相关
    Json城市列表
    Ubuntu安装SSH服务器故障分析及解决办法(错误1:E:软件包 openssh-server 还没有可供安装的候选者,错误2:E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系)
    小样儿老师:我的嵌入式学习之路(一)
    J
    归并排序的相关用法
    I
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7074247.html
Copyright © 2011-2022 走看看