码迷,mamicode.com
首页 > 其他好文 > 详细

集成激光推送

时间:2015-07-18 00:24:01      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

 

1.进入https://www.jpush.cn/common/products,注册用户,下载ADK,查看使用说明

 

2.简单的在AppDelegate中添加如下代码

#import "AppDelegate.h"

#import "APService.h"

@interface AppDelegate ()

 

@end

 

@implementation AppDelegate

 

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    //2ef3e25980d0a77068b83b89

    [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |UIUserNotificationTypeSound |UIUserNotificationTypeAlert)

                                       categories:nil];

    

    //launchOptions  远程通知的内容

    [APService setupWithOption:launchOptions];

    return YES;

}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

{

    //设置用户的别名  账号 而且每个人不一样

    [APService setAlias:@"137" callbackSelector:nil object:nil];

    

    //上传DeviceToken

    [APService registerDeviceToken:deviceToken];

}

 

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

    

    // Required

    [APService handleRemoteNotification:userInfo];

}

//后台 真后台

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

 

    // IOS 7 Support Required

    //[APService handleRemoteNotification:userInfo];

    

    //代码块

    //后台 还在继续运行  (下载  加载图片信息 -> 耗时 : 30)

    completionHandler(UIBackgroundFetchResultNewData);

}

集成激光推送

标签:

原文地址:http://www.cnblogs.com/tangranyang/p/4655860.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!