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