升级ios 库到 2.1.0

This commit is contained in:
darkterrorooo 2016-01-21 15:15:48 +08:00
parent 3d46fbc9ba
commit 3f9454edf3
12 changed files with 1018 additions and 663 deletions

View File

@ -1,6 +1,17 @@
l## JPush PhoneGap Plugin ##
## JPush PhoneGap Plugin ##
jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
**功能特性:**
>+ 发送推送通知
+ 发送推送自定义消息
+ 设置推送标签和别名
+ 设置角标iOS
*如需要 IM 功能插件,请关注[jmessage-phonegap-plugin](https://github.com/jpush/jmessage-phonegap-plugin)*
## 安装 ##
###准备工作
1. cordova create 文件夹名字 包名 应用名字
@ -68,12 +79,6 @@ l## JPush PhoneGap Plugin ##
该项目基于cordova实现目前无法使用'phonegap build'云服务进行打包,建议使用本地环境进行打包
###常见错误
1. androd
eclipse中phonegap工程import之后出现:`Type CallbackContext cannot be resolved to a type`
解决方案eclipse中右键单击工程名Build Path->Config Build Path->Projects->选中 工程名称CordovaLib->点击 add
### API说明
插件的API集中在JPushPlugin.js文件中,这个文件的位置如下
@ -188,5 +193,20 @@ l## JPush PhoneGap Plugin ##
[Android API详细说明](document/Android_detail_api.md)
###常见问题
####1. androd
eclipse中phonegap工程import之后出现:`Type CallbackContext cannot be resolved to a type`
解决方案eclipse中右键单击工程名Build Path->Config Build Path->Projects->选中 工程名称CordovaLib->点击 add
####2. iOS 设置/修改 APP_KEY
在PushConfig.plist 中修改。PushConfig.plist 其他值说明:
CHANNEL 渠道标识
IsProduction 是否生产环境(暂未启用)
###更多
[JPush官网文档](http://docs.jpush.io/)

View File

@ -1,210 +1,224 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Phonegap Sample App</title>
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
var onDeviceReady = function(){
console.log("JPushPlugin:Device ready!")
initiateUI();
}
var onGetRegistradionID = function(data) {
try{
console.log("JPushPlugin:registrationID is "+data)
$("#registrationid").html(data);
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Phonegap Sample App</title>
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
var onDeviceReady = function () {
console.log("JPushPlugin:Device ready!");
initiateUI();
};
function getRegistrationID() {
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
}
var onGetRegistradionID = function (data) {
try {
console.log("JPushPlugin:registrationID is " + data);
if (data.length == 0) {
var t1 = window.setTimeout(getRegistrationID, 1000);
}
catch(exception){
$("#registrationid").html(data);
}
catch (exception) {
console.log(exception);
}
};
var onTagsWithAlias = function (event) {
try {
console.log("onTagsWithAlias");
var result = "result code:" + event.resultCode + " ";
result += "tags:" + event.tags + " ";
result += "alias:" + event.alias + " ";
$("#tagAliasResult").html(result);
}
catch (exception) {
console.log(exception)
}
};
var onOpenNotification = function (event) {
try {
var alertContent;
if (device.platform == "Android") {
alertContent = window.plugins.jPushPlugin.openNotification.alert;
} else {
alertContent = event.aps.alert;
}
alert("open Notificaiton:" + alertContent);
}
catch (exception) {
console.log("JPushPlugin:onOpenNotification" + exception);
}
};
var onReceiveNotification = function (event) {
try {
var alertContent;
if (device.platform == "Android") {
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
} else {
alertContent = event.aps.alert;
}
$("#notificationResult").html(alertContent);
}
catch (exeption) {
console.log(exception)
}
};
var onReceiveMessage = function (event) {
try {
var message;
if (device.platform == "Android") {
message = window.plugins.jPushPlugin.receiveMessage.message;
} else {
message = event.content;
}
//var extras = window.plugins.jPushPlugin.extras
$("#messageResult").html(message);
}
catch (exception) {
console.log("JPushPlugin:onReceiveMessage-->" + exception);
}
};
var initiateUI = function () {
try {
window.plugins.jPushPlugin.init();
getRegistrationID();
if (device.platform != "Android") {
window.plugins.jPushPlugin.setDebugModeFromIos();
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
} else {
window.plugins.jPushPlugin.setDebugMode(true);
}
}
catch (exception) {
console.log(exception);
}
$("#setTagWithAliasButton").click(function (ev) {
// window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(data){
// console.log(data);
// });
try {
var tag1 = $("#tagText1").attr("value");
var tag2 = $("#tagText2").attr("value");
var tag3 = $("#tagText3").attr("value");
var alias = $("#aliasText").attr("value");
var dd = [];
if (tag1 == "" && tag2 == "" && tag3 == "") {
}
else {
if (tag1 != "") {
dd.push(tag1);
}
if (tag2 != "") {
dd.push(tag2);
}
if (tag3 != "") {
dd.push(tag3);
}
}
window.plugins.jPushPlugin.setTagsWithAlias(dd, alias);
}
catch (exception) {
console.log(exception);
}
}
var onTagsWithAlias = function(event){
try{
console.log("onTagsWithAlias");
var result="result code:"+event.resultCode+" ";
result+="tags:"+event.tags+" ";
result+="alias:"+event.alias+" ";
$("#tagAliasResult").html(result);
}
catch(exception){
console.log(exception)
}
}
var onOpenNotification = function(event){
try{
var alertContent
if(device.platform == "Android"){
alertContent=window.plugins.jPushPlugin.openNotification.alert;
}else{
alertContent = event.aps.alert;
}
alert("open Notificaiton:"+alertContent);
}
catch(exception){
console.log("JPushPlugin:onOpenNotification"+exception);
}
}
var onReceiveNotification = function(event){
try{
var alertContent
if(device.platform == "Android"){
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
}else{
alertContent = event.aps.alert;
}
$("#notificationResult").html(alertContent);
}
catch(exeption){
console.log(exception)
}
}
var onReceiveMessage = function(event){
try{
var message
if(device.platform == "Android"){
message = window.plugins.jPushPlugin.receiveMessage.message;
}else{
message = event.content;
}
//var extras = window.plugins.jPushPlugin.extras
$("#messageResult").html(message);
}
catch(exception){
console.log("JPushPlugin:onReceiveMessage-->"+exception);
}
}
var initiateUI = function(){
try{
window.plugins.jPushPlugin.init();
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
if(device.platform != "Android"){
window.plugins.jPushPlugin.setDebugModeFromIos();
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
}else{
window.plugins.jPushPlugin.setDebugMode(true);
}
}
catch(exception){
console.log(exception);
}
$("#setTagWithAliasButton").click(function(ev) {
try{
var tag1 = $("#tagText1").attr("value");
var tag2 = $("#tagText2").attr("value");
var tag3 = $("#tagText3").attr("value");
var alias = $("#aliasText").attr("value");
var dd = [];
if(tag1==""&&tag2==""&&tag3==""){
}
else{
if(tag1 != ""){
dd.push(tag1);
}
if(tag2 != ""){
dd.push(tag2);
}
if(tag3 != ""){
dd.push(tag3);
}
}
window.plugins.jPushPlugin.setTagsWithAlias(dd,alias);
}
catch(exception){
console.log(exception);
}
})
}
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("jpush.openNotification", onOpenNotification, false);
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);
})
};
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("jpush.openNotification", onOpenNotification, false);
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);
//jpush.receiveMessage
</script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="content">
<form>
<div class="ui-body ui-body-b">
<div data-role="fieldcontain">
<center><h3>JPushPlugin Example</h3></center>
<span name="alias" id="alias"></span><hr />
<label>RegistrationID: </label>
<label id="registrationid">null</label>
</div>
<div data-role="fieldcontain">
<label>Tags: </label>
<table>
<tr>
<td>
<input type="text" id="tagText1"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="tagText2"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="tagText3">
</td>
</tr>
</table>
<label>Alias: </label>
<table>
<tr>
<td>
<input type="text" id="aliasText">
</td>
</tr>
</table>
</div>
<div data-role="fieldcontain">
<input type="button" id="setTagWithAliasButton" value="Add tag and alias" />
</div>
<div data-role="fieldcontain">
<label id="tagAliasPrompt" >设置tag/alias结果 </label>
<label id="tagAliasResult" >null</label>
</div>
<div data-role="fieldcontain">
<label id="notificationPrompt" >接受的通知内容:</label>
<label id="notificationResult" >null</label>
</div>
<div data-role="fieldcontain">
<label id="messagePrompt" >接受的自定义消息:</label>
<label id="messageResult" >null</label>
</div>
//jpush.receiveMessage
</script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="content">
<form>
<div class="ui-body ui-body-b">
<div data-role="fieldcontain">
<center><h3>JPushPlugin Example</h3></center>
<span name="alias" id="alias"></span>
<hr/>
<label>RegistrationID: </label>
<label id="registrationid">null</label>
</div>
<div data-role="fieldcontain">
<label>Tags: </label>
<table>
<tr>
<td>
<input type="text" id="tagText1"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="tagText2"/>
</td>
</tr>
<tr>
<td>
<input type="text" id="tagText3">
</td>
</tr>
</table>
<label>Alias: </label>
<table>
<tr>
<td>
<input type="text" id="aliasText">
</td>
</tr>
</table>
</div>
<div data-role="fieldcontain">
<input type="button" id="setTagWithAliasButton" value="Add tag and alias"/>
</div>
<div data-role="fieldcontain">
<label id="tagAliasPrompt">设置tag/alias结果 </label>
<label id="tagAliasResult">null</label>
</div>
<div data-role="fieldcontain">
<label id="notificationPrompt">接受的通知内容:</label>
<label id="notificationResult">null</label>
</div>
<div data-role="fieldcontain">
<label id="messagePrompt">接受的自定义消息:</label>
<label id="messageResult">null</label>
</div>
</div>
</form>
</div>
</div>
</body>
</form>
</div>
</div>
</body>
</html>

View File

@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cn.jpush.phonegap.JPushPlugin"
version="2.0.6">
version="2.1.0">
<name>JPush Plugin</name>
<description>JPush for cordova plugin</description>
@ -30,8 +30,8 @@
<header-file src="src/ios/Plugins/JPushPlugin.h"/>
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
<header-file src="src/ios/lib/APService.h" />
<source-file src="src/ios/lib/libPushSDK-1.8.8.a" framework="true" />
<header-file src="src/ios/lib/JPUSHService.h" />
<source-file src="src/ios/lib/jpush-ios-2.1.0.a" framework="true" />
<header-file src="src/ios/Plugins/AppDelegate+JPush.h"/>
<source-file src="src/ios/Plugins/AppDelegate+JPush.m"/>
<resource-file src="src/ios/PushConfig.plist" />

View File

@ -9,9 +9,9 @@
#import "AppDelegate+JPush.h"
#import <objc/runtime.h>
#import "JPushPlugin.h"
#import "APService.h"
#import "JPUSHService.h"
static char launchNotificationKey;
//static char launchNotificationKey;
@implementation AppDelegate (JPush)
@ -41,25 +41,42 @@ static char launchNotificationKey;
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[APService registerDeviceToken:deviceToken];
[JPUSHService registerDeviceToken:deviceToken];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
[APService handleRemoteNotification:userInfo];
[JPUSHService handleRemoteNotification:userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
object:userInfo];
}
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
[APService handleRemoteNotification:userInfo];
[JPUSHService handleRemoteNotification:userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
object:userInfo];
}
- (void)application:(UIApplication *)application
didReceiveLocalNotification:(UILocalNotification *)notification {
[JPUSHService showLocalNotificationAtFront:notification identifierKey:nil];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// [application setApplicationIconBadgeNumber:0];
// [application cancelAllLocalNotifications];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
//delegate
//-(NSDictionary *)luanchOption{
// return objc_getAssociatedObject(self, &launchNotificationKey);

View File

@ -22,4 +22,17 @@
-(void)startLogPageView:(CDVInvokedUrlCommand*)command;
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command;
// 设置角标到服务器, 服务器下一次发消息时,会设置成这个值
//本接口不会改变应用本地的角标值.
-(void)setBadge:(CDVInvokedUrlCommand*)command;
//相当于 [setBadge:0]
-(void)resetBadge:(CDVInvokedUrlCommand*)command;
//改变应用本地的角标值.
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
//获取应用本地的角标值.
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
@end

View File

@ -7,335 +7,454 @@
//
#import "JPushPlugin.h"
#import "APService.h"
#import "JPUSHService.h"
#import <UIKit/UIKit.h>
static NSString *const JM_APP_KEY = @"APP_KEY";
static NSString *const JM_APP_CHANNEL = @"CHANNEL";
static NSString *const JM_APP_ISPRODUCTION = @"IsProduction";
static NSString *const JMessageConfigFileName = @"PushConfig";
static NSDictionary *_luanchOptions=nil;
@implementation JPushPlugin
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
_luanchOptions=theLaunchOptions;
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
[APService setupWithOption:_luanchOptions];
_luanchOptions=theLaunchOptions;
[JPUSHService setDebugMode];
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];
}
//read appkey and channel from JMessageConfig.plist
NSString *plistPath = [[NSBundle mainBundle] pathForResource:JMessageConfigFileName ofType:@"plist"];
if (plistPath == nil) {
NSLog(@"error: PushConfig.plist not found");
assert(0);
}
NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
NSString * appkey = [plistData valueForKey:JM_APP_KEY];
NSString * channel = [plistData valueForKey:JM_APP_CHANNEL];
NSNumber * isProduction = [plistData valueForKey:JM_APP_ISPRODUCTION];
if (!appkey || appkey.length == 0) {
NSLog(@"error: app key not found in JMessageConfig.plist ");
assert(0);
}
[JPUSHService setupWithOption:_luanchOptions appKey:appkey
channel:channel apsForProduction:[isProduction boolValue] ];
}
-(void)initial:(CDVInvokedUrlCommand*)command{
//do nithng,because Cordova plugin use lazy load mode.
}
- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView{
if (self=[super initWithWebView:theWebView]) {
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(networkDidReceiveMessage:)
name:kJPFNetworkDidReceiveMessageNotification
object:nil];
[defaultCenter addObserver:self
selector:@selector(networkDidReceiveNotification:)
name:kJPushPluginReceiveNotification
object:nil];
if (_luanchOptions) {
NSDictionary *userInfo = [_luanchOptions
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if ([userInfo count] >0) {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
if (!error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
});
}
}
}
}
return self;
-(void)stopPush:(CDVInvokedUrlCommand*)command{
[[UIApplication sharedApplication]unregisterForRemoteNotifications];
}
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<2) {
// [self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",@""]];
return ;
}
NSString *alias=[arguments objectAtIndex:0];
NSArray *arrayTags=[arguments objectAtIndex:1];
NSSet* set=[NSSet setWithArray:arrayTags];
[APService setTags:set
alias:alias
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
object:self];
}
-(void)resumePush:(CDVInvokedUrlCommand*)command{
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
//categories
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
} else {
//categories nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
}
#else
[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
} else {
//categories nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
[JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
}
#else
//categories nil
[JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
#endif
}
-(void)isPushStopped:(CDVInvokedUrlCommand*)command{
NSNumber *result;
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications ]) {
result=@(0);
}else{
result=@(1);
}
CDVPluginResult * pushResult=[self pluginResultForValue:result];
if (pushResult) {
[self succeedWithPluginResult:pushResult withCallbackID:command.callbackId];
} else {
[self failWithCallbackID:command.callbackId];
}
}
-(void)initial:(CDVInvokedUrlCommand*)command{
//do nithng,because Cordova plugin use lazy load mode.
}
#ifdef __CORDOVA_4_0_0
- (void)pluginInitialize {
NSLog(@"### pluginInitialize ");
[self initNotifications];
}
#else
- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView{
NSLog(@"### initWithWebView ");
if (self=[super initWithWebView:theWebView]) {
[self initNotifications];
}
return self;
}
#endif
}
-(void)isPushStopped:(CDVInvokedUrlCommand*)command{
NSNumber *result;
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications ]) {
result=@(0);
}else{
result=@(1);
-(void)initNotifications {
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(networkDidReceiveMessage:)
name:kJPFNetworkDidReceiveMessageNotification
object:nil];
[defaultCenter addObserver:self
selector:@selector(networkDidReceiveNotification:)
name:kJPushPluginReceiveNotification
object:nil];
if (_luanchOptions) {
NSDictionary *userInfo = [_luanchOptions
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if ([userInfo count] >0) {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
if (!error) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
});
}
}
CDVPluginResult * pushResult=[self pluginResultForValue:result];
if (pushResult) {
[self succeedWithPluginResult:pushResult withCallbackID:command.callbackId];
} else {
[self failWithCallbackID:command.callbackId];
}}
-(void)setTags:(CDVInvokedUrlCommand *)command{
}
}
NSArray *arguments=[command arguments];
NSString *tags=[arguments objectAtIndex:0];
NSArray *array=[tags componentsSeparatedByString:@","];
[APService setTags:[NSSet setWithArray:array]
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
object:self];
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<2) {
NSLog(@"#### setTagsWithAlias param is less");
return ;
}
NSString *alias=[arguments objectAtIndex:0];
NSArray *arrayTags=[arguments objectAtIndex:1];
NSLog(@"#### setTagsWithAlias alias is %@, tags is %@",alias,arrayTags);
NSSet* set=[NSSet setWithArray:arrayTags];
[JPUSHService setTags:set
alias:alias
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
object:self];
}
-(void)setTags:(CDVInvokedUrlCommand *)command{
NSArray *arguments=[command arguments];
NSString *tags=[arguments objectAtIndex:0];
NSLog(@"#### setTags %@",tags);
NSArray *array=[tags componentsSeparatedByString:@","];
[JPUSHService setTags:[NSSet setWithArray:array]
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
object:self];
}
-(void)setAlias:(CDVInvokedUrlCommand *)command{
NSArray *arguments=[command arguments];
[APService setAlias:[arguments objectAtIndex:0]
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
object:self];
NSArray *arguments=[command arguments];
NSLog(@"#### setAlias %@",arguments);
[JPUSHService setAlias:[arguments objectAtIndex:0]
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
object:self];
}
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
NSString* registrationID = [APService registrationID];
CDVPluginResult *result=[self pluginResultForValue:registrationID];
if (result) {
[self succeedWithPluginResult:result withCallbackID:command.callbackId];
} else {
[self failWithCallbackID:command.callbackId];
}
NSString* registrationID = [JPUSHService registrationID];
NSLog(@"### getRegistrationID %@",registrationID);
CDVPluginResult *result=[self pluginResultForValue:registrationID];
if (result) {
[self succeedWithPluginResult:result withCallbackID:command.callbackId];
} else {
[self failWithCallbackID:command.callbackId];
}
}
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias{
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:resultCode],@"resultCode",
tags==nil?[NSNull null]:[tags allObjects],@"tags",
alias==nil?[NSNull null]:alias,@"alias",nil];
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data setObject:[NSNumber numberWithInt:resultCode] forKey:@"resultCode"];
[data setObject:tags==nil?[NSNull null]:[tags allObjects] forKey:@"tags"];
[data setObject:alias==nil?[NSNull null]:alias forKey:@"alias"];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",jsonString]];
// [self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
});
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:resultCode],@"resultCode",
tags==nil?[NSNull null]:[tags allObjects],@"tags",
alias==nil?[NSNull null]:alias,@"alias",nil];
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data setObject:[NSNumber numberWithInt:resultCode] forKey:@"resultCode"];
[data setObject:tags==nil?[NSNull null]:[tags allObjects] forKey:@"tags"];
[data setObject:alias==nil?[NSNull null]:alias forKey:@"alias"];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",jsonString]];
// [self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
});
}
-(void)startLogPageView:(CDVInvokedUrlCommand*)command{
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<1) {
NSLog(@"startLogPageView argument error");
return ;
}
NSString * pageName=[arguments objectAtIndex:0];
if (pageName) {
[APService startLogPageView:pageName];
}
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<1) {
NSLog(@"startLogPageView argument error");
return ;
}
NSString * pageName=[arguments objectAtIndex:0];
if (pageName) {
[JPUSHService startLogPageView:pageName];
}
}
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command{
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<1) {
NSLog(@"stopLogPageView argument error");
return ;
}
NSString * pageName=[arguments objectAtIndex:0];
if (pageName) {
[APService stopLogPageView:pageName];
}
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<1) {
NSLog(@"stopLogPageView argument error");
return ;
}
NSString * pageName=[arguments objectAtIndex:0];
if (pageName) {
[JPUSHService stopLogPageView:pageName];
}
}
-(void)beginLogPageView:(CDVInvokedUrlCommand*)command{
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<2) {
NSLog(@"beginLogPageView argument error");
return ;
}
NSString * pageName=[arguments objectAtIndex:0];
int duration=[[arguments objectAtIndex:0]intValue];
if (pageName) {
[APService beginLogPageView:pageName duration:duration];
}
NSArray *arguments=command.arguments;
if (!arguments||[arguments count]<2) {
NSLog(@"beginLogPageView argument error");
return ;
}
NSString * pageName=[arguments objectAtIndex:0];
int duration=[[arguments objectAtIndex:0]intValue];
if (pageName) {
[JPUSHService beginLogPageView:pageName duration:duration];
}
}
-(void)setBadge:(CDVInvokedUrlCommand*)command{
NSArray *argument=command.arguments;
if ([argument count]<1) {
NSLog(@"setBadge argument error!");
return;
}
NSNumber *badge=[argument objectAtIndex:0];
[APService setBadge:[badge intValue]];
NSArray *argument=command.arguments;
if ([argument count]<1) {
NSLog(@"setBadge argument error!");
return;
}
NSNumber *badge=[argument objectAtIndex:0];
[JPUSHService setBadge:[badge intValue]];
}
-(void)resetBadge:(CDVInvokedUrlCommand*)command{
[APService resetBadge];
}
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command{
[APService setDebugMode];
}
-(void)setLogOFF:(CDVInvokedUrlCommand*)command{
[APService setLogOFF];
}
-(void)stopPush:(CDVInvokedUrlCommand*)command{
[[UIApplication sharedApplication]unregisterForRemoteNotifications];
-(void)resetBadge:(CDVInvokedUrlCommand*)command{
[JPUSHService resetBadge];
}
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command{
//
NSArray *argument=command.arguments;
if ([argument count]<1) {
NSLog(@"setBadge argument error!");
return;
}
NSNumber *badge=[argument objectAtIndex:0];
[UIApplication sharedApplication].applicationIconBadgeNumber=[badge intValue];
}
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
NSInteger num = [UIApplication sharedApplication].applicationIconBadgeNumber;
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:num];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command{
[JPUSHService setDebugMode];
}
-(void)setLogOFF:(CDVInvokedUrlCommand*)command{
[JPUSHService setLogOFF];
}
- (void)failWithCallbackID:(NSString *)callbackID {
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
}
- (void)succeedWithPluginResult:(CDVPluginResult *)result withCallbackID:(NSString *)callbackID {
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
}
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command{
//
NSArray *argument=command.arguments;
if ([argument count]<1) {
NSLog(@"setBadge argument error!");
return;
}
NSNumber *badge=[argument objectAtIndex:0];
[UIApplication sharedApplication].applicationIconBadgeNumber=[badge intValue];
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
}
- (CDVPluginResult *)pluginResultForValue:(id)value {
CDVPluginResult *result;
if ([value isKindOfClass:[NSString class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsString:[value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
} else if ([value isKindOfClass:[NSNumber class]]) {
CFNumberType numberType = CFNumberGetType((CFNumberRef)value);
//note: underlyingly, BOOL values are typedefed as char
if (numberType == kCFNumberIntType || numberType == kCFNumberCharType) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:[value intValue]];
} else {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[value doubleValue]];
}
} else if ([value isKindOfClass:[NSArray class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:value];
} else if ([value isKindOfClass:[NSDictionary class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:value];
} else if ([value isKindOfClass:[NSNull class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
} else {
NSLog(@"Cordova callback block returned unrecognized type: %@", NSStringFromClass([value class]));
return nil;
CDVPluginResult *result;
if ([value isKindOfClass:[NSString class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsString:[value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
} else if ([value isKindOfClass:[NSNumber class]]) {
CFNumberType numberType = CFNumberGetType((CFNumberRef)value);
//note: underlyingly, BOOL values are typedefed as char
if (numberType == kCFNumberIntType || numberType == kCFNumberCharType) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:[value intValue]];
} else {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[value doubleValue]];
}
return result;
} else if ([value isKindOfClass:[NSArray class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:value];
} else if ([value isKindOfClass:[NSDictionary class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:value];
} else if ([value isKindOfClass:[NSNull class]]) {
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
} else {
NSLog(@"Cordova callback block returned unrecognized type: %@", NSStringFromClass([value class]));
return nil;
}
return result;
}
- (void)networkDidReceiveMessage:(NSNotification *)notification {
NSDictionary *userInfo = [notification userInfo];
//NSLog(@"%@",userInfo);
NSDictionary *userInfo = [notification userInfo];
//NSLog(@"%@",userInfo);
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
//NSLog(@"%@",jsonString);
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
//NSLog(@"%@",jsonString);
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveMessage',%@)",jsonString]];
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveMessage',%@)",jsonString]];
[self.commandDelegate evalJs:[NSString stringWithFormat:@"window.plugins.jPushPlugin.receiveMessageIniOSCallback('%@')",jsonString]];
});
[self.commandDelegate evalJs:[NSString stringWithFormat:@"window.plugins.jPushPlugin.receiveMessageIniOSCallback('%@')",jsonString]];
});
}
-(void)networkDidReceiveNotification:(id)notification{
NSError *error;
NSDictionary *userInfo = [notification object];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateActive:
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
});
}
break;
case UIApplicationStateInactive:
case UIApplicationStateBackground:
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
});
}
break;
default:
//do nothing
break;
NSError *error;
NSDictionary *userInfo = [notification object];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateActive:
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
});
}
break;
case UIApplicationStateInactive:
case UIApplicationStateBackground:
{
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
});
}
break;
default:
//do nothing
break;
}
}

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>APP_KEY</key>
<string></string>
<key>CHANNEL</key>
<string>Subscription</string>
</dict>
<dict>
<key>APP_KEY</key>
<string></string>
<key>CHANNEL</key>
<string>Subscription</string>
<key>IsProduction</key>
<false/>
</dict>
</plist>

View File

@ -1,175 +0,0 @@
//
// APService.h
// APService
//
// Created by JPush on 12-8-15.
// Copyright (c) 2012年 HXHG. All rights reserved.
// Version: 1.8.8
@class CLRegion;
@class UILocalNotification;
extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接
extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接
extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功
extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功
extern NSString *const
kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
extern NSString *const kJPFServiceErrorNotification; // 错误提示
@class CLLocation;
@interface APService : NSObject
#pragma - mark 基本功能
// 以下四个接口是必须调用的
+ (void)setupWithOption:(NSDictionary *)launchingOption; // 初始化
+ (void)registerForRemoteNotificationTypes:(NSUInteger)types
categories:(NSSet *)categories; // 注册APNS类型
+ (void)registerDeviceToken:(NSData *)deviceToken; // 向服务器上报Device Token
+ (void)handleRemoteNotification:(NSDictionary *)
remoteInfo; // 处理收到的APNS消息向服务器上报收到APNS消息
// 下面的接口是可选的
// 设置标签和(或)别名若参数为nil则忽略若是空对象则清空详情请参考文档http://docs.jpush.cn/pages/viewpage.action?pageId=3309913
+ (void)setTags:(NSSet *)tags
alias:(NSString *)alias
callbackSelector:(SEL)cbSelector
target:(id)theTarget;
+ (void)setTags:(NSSet *)tags
alias:(NSString *)alias
callbackSelector:(SEL)cbSelector
object:(id)theTarget;
+ (void)setTags:(NSSet *)tags
callbackSelector:(SEL)cbSelector
object:(id)theTarget;
+ (void)setAlias:(NSString *)alias
callbackSelector:(SEL)cbSelector
object:(id)theTarget;
// 用于过滤出正确可用的tags如果总数量超出最大限制则返回最大数量的靠前的可用tags
+ (NSSet *)filterValidTags:(NSSet *)tags;
#pragma - mark 上报日志
/**
*
* startLogPageView和stopLogPageView为自动计算停留时间
* beginLogPageView为手动自己输入停留时间
*
* @param pageName
* @param seconds
*/
+ (void)startLogPageView:(NSString *)pageName;
+ (void)stopLogPageView:(NSString *)pageName;
+ (void)beginLogPageView:(NSString *)pageName duration:(int)seconds;
/**
* Crash日志收集, .
*/
+ (void)crashLogON;
/**
*
*
* CoreLocation.framework #import <CoreLocation/CoreLocation.h>
* @param latitude .
* @param longitude .
* @param location CLLocation *
*/
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
+ (void)setLocation:(CLLocation *)location;
#pragma - mark 本地通知
/**
* 64
* @param fireDate
* @param alertBody
* @param badge -1
* @param alertAction IOS 8"打开","启动"
* @param notificationKey
* @param userInfo
* @param soundName nil为默认声音
* IOS8新参数
* @param region
* @param regionTriggersOnce
* @param category
*/
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
alertBody:(NSString *)alertBody
badge:(int)badge
alertAction:(NSString *)alertAction
identifierKey:(NSString *)notificationKey
userInfo:(NSDictionary *)userInfo
soundName:(NSString *)soundName;
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
alertBody:(NSString *)alertBody
badge:(int)badge
alertAction:(NSString *)alertAction
identifierKey:(NSString *)notificationKey
userInfo:(NSDictionary *)userInfo
soundName:(NSString *)soundName
region:(CLRegion *)region
regionTriggersOnce:(BOOL)regionTriggersOnce
category:(NSString *)category
NS_AVAILABLE_IOS(8_0);
/**
* App在前台运行时不会进行弹窗
* @param notification
* @param notificationKey
*/
+ (void)showLocalNotificationAtFront:(UILocalNotification *)notification
identifierKey:(NSString *)notificationKey;
/**
*
* @param notificationKey
* @param myUILocalNotification
*/
+ (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey;
+ (void)deleteLocalNotification:(UILocalNotification *)localNotification;
/**
*
* @param notificationKey
* @return ,[array count]0
*/
+ (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey;
/**
*
*/
+ (void)clearAllLocalNotifications;
#pragma - mark 设置Badge
/**
* set setBadge
* @param value JPush服务器的badge的值
* UIApplication:setApplicationIconBadgeNumber函数,
*/
+ (BOOL)setBadge:(NSInteger)value;
/**
* set setBadge
* @param value JPush服务器对badge值的设定.
* UIApplication:setApplicationIconBadgeNumber函数,
*/
+ (void)resetBadge;
/**
* get RegistrationID
*/
+ (NSString *)registrationID;
#pragma - mark 打印日志信息配置
/**
* setDebugMode获取更多的Log信息
* DebugMode
*
* setLogOFF关闭除了错误信息外的所有Log
* LogOFF用于节省性能开销
*
* DebugLog,
*/
+ (void)setDebugMode;
+ (void)setLogOFF;
@end

337
src/ios/lib/JPUSHService.h Executable file
View File

@ -0,0 +1,337 @@
/*
* | | | | \ \ / / | | | | / _______|
* | |____| | \ \/ / | |____| | / /
* | |____| | \ / | |____| | | | _____
* | | | | / \ | | | | | | |____ |
* | | | | / /\ \ | | | | \ \______| |
* | | | | /_/ \_\ | | | | \_________|
*
* Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
*/
#define JPUSH_VERSION_NUMBER 2.1.0
#import <Foundation/Foundation.h>
@class CLRegion;
@class UILocalNotification;
extern NSString *const kJPFNetworkIsConnectingNotification; // 正在连接中
extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接
extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接
extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功
extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功
extern NSString *const kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
extern NSString *const kJPFServiceErrorNotification; // 错误提示
@class CLLocation;
/*!
* JPush
*/
@interface JPUSHService : NSObject
///----------------------------------------------------
/// @name Setup 启动相关
///----------------------------------------------------
/*!
* @abstract SDK
*
* @discussion , PushConfig.plist . 使, .
*/
+ (void)setupWithOption:(NSDictionary *)launchingOption __attribute__((deprecated("JPush 2.1.0 版本已过期")));
/*!
* @abstract SDK
*
* @param launchingOption .
* @param appKey JPush ,. JPush .
* @param channel . .
* @param isProduction . , NO; , YES.
*
* @discussion SDK启动必须的参数, SDK.
* App , JPush SDK .
*/
+ (void)setupWithOption:(NSDictionary *)launchingOption
appKey:(NSString *)appKey
channel:(NSString *)channel
apsForProduction:(BOOL)isProduction;
///----------------------------------------------------
/// @name APNs about 通知相关
///----------------------------------------------------
/*!
* @abstract
*
* @param types
* @param categories
*
* @discussion
*/
+ (void)registerForRemoteNotificationTypes:(NSUInteger)types
categories:(NSSet *)categories;
+ (void)registerDeviceToken:(NSData *)deviceToken;
/*!
* @abstract APNs
*/
+ (void)handleRemoteNotification:(NSDictionary *)remoteInfo;
///----------------------------------------------------
/// @name Tag alias setting 设置别名与标签
///----------------------------------------------------
/*!
*
* ()nilhttp://docs.jpush.io/client/ios_api/#api-ios
* setTags:alias:fetchCompletionHandle:block里面处理设置结果即可.
* WARN: 使block时需要注意循环引用问题
*/
+ (void) setTags:(NSSet *)tags
alias:(NSString *)alias
callbackSelector:(SEL)cbSelector
target:(id)theTarget;
+ (void) setTags:(NSSet *)tags
alias:(NSString *)alias
callbackSelector:(SEL)cbSelector
object:(id)theTarget;
+ (void) setTags:(NSSet *)tags
callbackSelector:(SEL)cbSelector
object:(id)theTarget;
+ (void) setTags:(NSSet *)tags
alias:(NSString *)alias
fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler;
+ (void) setTags:(NSSet *)tags
aliasInbackground:(NSString *)alias;
+ (void)setAlias:(NSString *)alias
callbackSelector:(SEL)cbSelector
object:(id)theTarget;
/*!
* @abstract tags
*
* @discussion tags , tags.
* tags . SDK .
*/
+ (NSSet *)filterValidTags:(NSSet *)tags;
///----------------------------------------------------
/// @name Stats 统计功能
///----------------------------------------------------
/*!
* @abstract
*
* @param pageName
*/
+ (void)startLogPageView:(NSString *)pageName;
/*!
* @abstract
*
* @param pageName
*/
+ (void)stopLogPageView:(NSString *)pageName;
/*!
* @abstract
*
* @param pageName
* @param seconds
*/
+ (void)beginLogPageView:(NSString *)pageName duration:(int)seconds;
/*!
* @abstract Crash日志收集
*
* @discussion .
*/
+ (void)crashLogON;
/*!
* @abstract
*
* @param latitude .
* @param longitude .
*
*/
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
/*!
* @abstract
*
* @param location CLLocation *
*
* @discussion CoreLocation.framework #import <CoreLocation/CoreLocation.h>
*/
+ (void)setLocation:(CLLocation *)location;
///----------------------------------------------------
/// @name Local Notification 本地通知
///----------------------------------------------------
/*!
* @abstract 64
*
* @param fireDate
* @param alertBody
* @param badge -1
* @param alertAction IOS 8"打开", "启动"
* @param notificationKey
* @param userInfo
* @param soundName nil为默认声音
*
* @discussion 64
*/
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
alertBody:(NSString *)alertBody
badge:(int)badge
alertAction:(NSString *)alertAction
identifierKey:(NSString *)notificationKey
userInfo:(NSDictionary *)userInfo
soundName:(NSString *)soundName;
/*!
* @abstract ( iOS8 )
*
* IOS8新参数
* @param region
* @param regionTriggersOnce
* @param category
*/
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
alertBody:(NSString *)alertBody
badge:(int)badge
alertAction:(NSString *)alertAction
identifierKey:(NSString *)notificationKey
userInfo:(NSDictionary *)userInfo
soundName:(NSString *)soundName
region:(CLRegion *)region
regionTriggersOnce:(BOOL)regionTriggersOnce
category:(NSString *)category NS_AVAILABLE_IOS(8_0);
/*!
* @abstract
*
* @param notification
* @param notificationKey
*
* @discussion App在前台运行时不会进行弹窗
*/
+ (void)showLocalNotificationAtFront:(UILocalNotification *)notification
identifierKey:(NSString *)notificationKey;
/*!
* @abstract
*
* @param notificationKey
* @param myUILocalNotification
*/
+ (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey;
/*!
* @abstract
*/
+ (void)deleteLocalNotification:(UILocalNotification *)localNotification;
/*!
* @abstract
*
* @param notificationKey
* @return , [array count]0
*/
+ (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey;
/*!
* @abstract
*/
+ (void)clearAllLocalNotifications;
///----------------------------------------------------
/// @name Server badge 服务器端 badge 功能
///----------------------------------------------------
/*!
* @abstract ()
*
* @param value . ()
*
* @discussion .
* UIApplication:setApplicationIconBadgeNumber .
*
* JPush .
* , APNs , , .
*
* JPush :
*
* - API () badge ;
* - API APNs (),
* 使 "+1" , badge () +1 badge ;
*/
+ (BOOL)setBadge:(NSInteger)value;
/*!
* @abstract (0)
*
* @discussion [setBadge:0] .
* [JPUSHService setBadge:] .
*/
+ (void)resetBadge;
///----------------------------------------------------
/// @name Logs and others 日志与其他
///----------------------------------------------------
/*!
* @abstract JPush标识此设备的 registrationID
*
* @discussion SDK注册成功后, registrationID .
*
* JPush registrationID .
* , registrationID , , .
*
* JPush .
*/
+ (NSString *)registrationID;
/*!
* @abstract Debug
*
* @discussion JMessage iOS Android .
* : Verbose, Debug, Info, Warning, Error.
* , Android .
*
* SDK : Info. , .
*
* : Debug, .
*/
+ (void)setDebugMode;
/*!
* @abstract
*
* @discussion , [JPUSHService setDebugMode]
*
* , Warning, Error . , , .
*
* , , .
*/
+ (void)setLogOFF;
@end

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,5 @@
var JPushPlugin = function(){
};
@ -43,9 +44,14 @@ JPushPlugin.prototype.beginLogPageView = function(pageName,duration){
}
JPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge){
if(this.isPlatformIOS()){
this.call_native( "setApplicationIconBadgeNumber",[badge],null);
this.call_native( "setApplicationIconBadgeNumber",[badge],null);
}
}
JPushPlugin.prototype.getApplicationIconBadgeNumber = function(callback){
if(this.isPlatformIOS()){
this.call_native( "getApplicationIconBadgeNumber",[],callback);
}
}
JPushPlugin.prototype.setTagsWithAlias = function(tags,alias){
try{
@ -328,3 +334,5 @@ if(!window.plugins.jPushPlugin){
module.exports = new JPushPlugin();