1.注册激光推送的账号 ----> 创建应用

2.上传推送测试和发布的p12文件  注意密码的填写

3.下载sdk并拖进工程里

4.在build setting 搜索search   把路径改一下

然后导入必须的库

CFNetwork.framework
CoreFoundation.framework
CoreTelephony.framework
SystemConfiguration.framework
CoreGraphics.framework
Foundation.framework
UIKit.framework
Security.framework
Xcode7需要的是libz.tbd;Xcode7以下版本是libz.dylib

配置plist文件

实现如下代码

AppDelegate.m
// 远程推送
//
// Created by  on 16/3/28.
// Copyright © 2016年 sjb. All rights reserved.
//
#import "AppDelegate.h"
#import "JPUSHService.h"

#define kJpushKey @"c171bc25d7754e085b48861b"
#define kMasterSecret (7f37465534cece94ac94c277)
static NSString *appKey = @"AppKey copied from JPush Portal application";

static NSString *channel = @"Publish channel";
static BOOL isProduction = FALSE;

@interface AppDelegate ()

@end

@implementation AppDelegate

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

if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
}else{
[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
}

[JPUSHService setupWithOption:launchOptions appKey:kJpushKey
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

最新文章

  1. JSP开发环境配置问题解答
  2. 应用HTK搭建语音拨号系统2:创建单音素HMM模型
  3. 【转】用C#调用Windows API向指定窗口发送
  4. HTML及简单标签介绍
  5. ios AFNetworking 有用篇
  6. HTML+CSS笔记 CSS进阶
  7. Mysql--选择适合的引擎,提高操作速度
  8. 彩扩机项目--NPN和PNP三极管作为开关管的区别
  9. python实战===使用随机的163账号发送邮件
  10. python连接mysql数据库读取数据
  11. python3 短网址和数字的相互转换的代码
  12. WPF 自定义Command
  13. 爬虫(三)之scrapy核心组件
  14. [leetcode]Partition List @ Python
  15. Direct2D教程VI——转换(Transform)
  16. ELK之生产日志收集构架(filebeat-logstash-redis-logstash-elasticsearch-kibana)
  17. 《Mysql 索引》
  18. POJ1639顶点度限制最小生成树
  19. jq移除最后一个class的值
  20. 05-oralce转换函数

热门文章

  1. BHuman文档结构
  2. 获取Storyboard中的视图控制器
  3. STURTS2 HELLOWORLD
  4. python爬虫框架scrapy初试(二)
  5. 挖坑:CF712E
  6. jquery css hover
  7. DevExpress的SpinEdit控件无法输入数字的问题
  8. PDF在线阅读 FlexPaper 惰性加载 ;
  9. 谷歌游览器对<input type='file'> change只能响应1次解决和样式的改变
  10. openwrt 添加 应用(luci-application)