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
    

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

  • 相关阅读:
    error MSB8031(将vs2010的工程用vs2013打开时出的错)
    MFC如何使控件大小随着对话框大小自动调整
    基于MFC对话框程序中添加菜单栏 (CMenu)
    mfc改变对话框窗口大小
    MFC设置对话框大小
    uart与usart区别
    uart接口介绍和认识
    USB引脚属性
    使用百度云服务器BCC搭建网站,过程记录
    linux下文件的复制、移动与删除命令为:cp,mv,rm
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7074247.html
Copyright © 2011-2022 走看看