mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-19 05:22:57 +08:00
Merge pull request #139 from jpush/dev
This commit is contained in:
commit
661b216359
11
README.md
11
README.md
@ -134,20 +134,29 @@ jpush-phonegap-plugin 支持 iOS,Android 的推送插件。
|
|||||||
window.plugins.jPushPlugin.startLogPageView (pageName)
|
window.plugins.jPushPlugin.startLogPageView (pageName)
|
||||||
window.plugins.jPushPlugin.stopLogPageView (pageName)
|
window.plugins.jPushPlugin.stopLogPageView (pageName)
|
||||||
window.plugins.jPushPlugin.beginLogPageView (pageName,duration)
|
window.plugins.jPushPlugin.beginLogPageView (pageName,duration)
|
||||||
|
|
||||||
+ 设置Badge
|
+ 设置Badge
|
||||||
|
|
||||||
window.plugins.jPushPlugin.setBadge(value)
|
window.plugins.jPushPlugin.setBadge(value)
|
||||||
window.plugins.jPushPlugin.resetBadge()
|
window.plugins.jPushPlugin.resetBadge()
|
||||||
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(badge)
|
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(badge)
|
||||||
|
window.plugins.JPushPlugin.getApplicationIconBadgeNumber(callback)
|
||||||
|
|
||||||
+ 本地通知
|
+ 本地通知
|
||||||
|
|
||||||
+ 后续版本加入
|
window.plugins.JPushPlugin.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras)
|
||||||
|
window.plugins.JPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS()
|
||||||
|
window.plugins.JPushPlugin.clearAllLocalNotifications()
|
||||||
|
|
||||||
+ 日志等级设置
|
+ 日志等级设置
|
||||||
|
|
||||||
window.plugins.jPushPlugin.setDebugModeFromIos ()
|
window.plugins.jPushPlugin.setDebugModeFromIos ()
|
||||||
window.plugins.jPushPlugin.setLogOFF()
|
window.plugins.jPushPlugin.setLogOFF()
|
||||||
|
window.plugins.JPushPlugin.setCrashLogON()
|
||||||
|
|
||||||
|
+ 地理位置上报
|
||||||
|
|
||||||
|
window.plugins.JPushPlugin.setLocation(latitude, longitude)
|
||||||
|
|
||||||
[iOS API详细说明](document/iOS_detail_api.md)
|
[iOS API详细说明](document/iOS_detail_api.md)
|
||||||
|
|
||||||
|
@ -87,14 +87,14 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
|
|||||||
+ callback 回调函数,用来通知JPush的推送服务是否开启
|
+ callback 回调函数,用来通知JPush的推送服务是否开启
|
||||||
|
|
||||||
####代码示例
|
####代码示例
|
||||||
window.plugins.jPushPlugin.resumePush(callback)
|
window.plugins.jPushPlugin.resumePush(callback)
|
||||||
var onCallback = function(data) {
|
var onCallback = function(data) {
|
||||||
if(data>0){
|
if(data>0){
|
||||||
//开启
|
//开启
|
||||||
}else{
|
}else{
|
||||||
//关闭
|
//关闭
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
##获取 RegistrationID API
|
##获取 RegistrationID API
|
||||||
@ -136,7 +136,7 @@ RegistrationID 定义
|
|||||||
|
|
||||||
这几个 API 可以在 App 里任何地方调用。
|
这几个 API 可以在 App 里任何地方调用。
|
||||||
|
|
||||||
别名 alias
|
**别名 alias**
|
||||||
|
|
||||||
为安装了应用程序的用户,取个别名来标识。以后给该用户 Push 消息时,就可以用此别名来指定。
|
为安装了应用程序的用户,取个别名来标识。以后给该用户 Push 消息时,就可以用此别名来指定。
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ RegistrationID 定义
|
|||||||
|
|
||||||
举例:在一个用户要登录的游戏中,可能设置别名为 userid。游戏运营时,发现该用户 3 天没有玩游戏了,则根据 userid 调用服务器端API发通知到客户端提醒用户。
|
举例:在一个用户要登录的游戏中,可能设置别名为 userid。游戏运营时,发现该用户 3 天没有玩游戏了,则根据 userid 调用服务器端API发通知到客户端提醒用户。
|
||||||
|
|
||||||
标签 tag
|
**标签 tag**
|
||||||
|
|
||||||
为安装了应用程序的用户,打上标签。其目的主要是方便开发者根据标签,来批量下发 Push 消息。
|
为安装了应用程序的用户,打上标签。其目的主要是方便开发者根据标签,来批量下发 Push 消息。
|
||||||
|
|
||||||
@ -164,10 +164,6 @@ RegistrationID 定义
|
|||||||
JPushPlugin.prototype.setTags = function(tags)
|
JPushPlugin.prototype.setTags = function(tags)
|
||||||
JPushPlugin.prototype.setAlias = function(alias)
|
JPushPlugin.prototype.setAlias = function(alias)
|
||||||
|
|
||||||
####使用平台
|
|
||||||
android iOS
|
|
||||||
|
|
||||||
|
|
||||||
#### 参数说明
|
#### 参数说明
|
||||||
* tags
|
* tags
|
||||||
* 参数类型为数组
|
* 参数类型为数组
|
||||||
@ -207,17 +203,18 @@ android iOS
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|Code|描述|详细解释|
|
|Code|描述 |详细解释 |
|
||||||
|-|-|-|
|
|----|:----------------------------------------|:--------|
|
||||||
|6001| 无效的设置,tag/alias 不应参数都为 null||
|
|6001|无效的设置,tag/alias 不应参数都为 null | |
|
||||||
|6002| 设置超时| 建议重试|
|
|6002|设置超时 |建议重试|
|
||||||
|6003| alias| 字符串不合法 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。|
|
|6003|alias 字符串不合法 |有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。|
|
||||||
|6004| alias超长。最多 40个字节 中文 UTF-8 是 3 个字节|
|
|6004|alias超长。 |最多 40个字节 中文 UTF-8 是 3 个字节|
|
||||||
|6005| 某一个 tag 字符串不合法| 有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。|
|
|6005|某一个 tag 字符串不合法 |有效的别名、标签组成:字母(区分大小写)、数字、下划线、汉字。|
|
||||||
|6006| 某一个 tag 超长。|一个 tag 最多 40个字节 中文 UTF-8 是 3 个字节|
|
|6006|某一个 tag 超长 |一个 tag 最多 40个字节 中文 UTF-8 是 3 个字节|
|
||||||
|6007| tags 数量超出限制。最多 100个| 这是一台设备的限制。一个应用全局的标签数量无限制。|
|
|6007|tags 数量超出限制。最多 100个 |这是一台设备的限制。一个应用全局的标签数量无限制。|
|
||||||
|6008| tag/alias 超出总长度限制。|总长度最多 1K 字节|
|
|6008|tag/alias 超出总长度限制 |总长度最多 1K 字节|
|
||||||
|6011| 10s内设置tag或alias大于3次| 短时间内操作过于频繁|
|
|6011|10s内设置tag或alias大于3次 |短时间内操作过于频繁|
|
||||||
|
|
||||||
|
|
||||||
### 获取点击通知内容
|
### 获取点击通知内容
|
||||||
|
|
||||||
@ -264,6 +261,8 @@ ps:点击通知后传递的json object 保存在window.plugins.jPushPlugin.ope
|
|||||||
"sound":"default",
|
"sound":"default",
|
||||||
"alert":"今天去哪儿"
|
"alert":"今天去哪儿"
|
||||||
},
|
},
|
||||||
|
"key1":"value1",
|
||||||
|
"key2":"value2",
|
||||||
"_j_msgid":154604475
|
"_j_msgid":154604475
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,6 +311,8 @@ ps:点击通知后传递的json object 保存在window.plugins.jPushPlugin.rec
|
|||||||
"sound":"default",
|
"sound":"default",
|
||||||
"alert":"今天去哪儿"
|
"alert":"今天去哪儿"
|
||||||
},
|
},
|
||||||
|
"key1":"value1",
|
||||||
|
"key2":"value2",
|
||||||
"_j_msgid":154604475
|
"_j_msgid":154604475
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var initiateUI = function () {
|
var initiateUI = function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
window.plugins.jPushPlugin.init();
|
window.plugins.jPushPlugin.init();
|
||||||
getRegistrationID();
|
getRegistrationID();
|
||||||
|
@ -68,7 +68,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
private static String TAG = "JPushPlugin";
|
private static String TAG = "JPushPlugin";
|
||||||
|
|
||||||
private static boolean shouldCacheMsg = false;
|
private static boolean shouldCacheMsg = false;
|
||||||
private static boolean isStatisticsOpened = true; // 是否开启统计分析功能
|
private static boolean isStatisticsOpened = false; // 是否开启统计分析功能
|
||||||
|
|
||||||
public static String notificationAlert;
|
public static String notificationAlert;
|
||||||
public static Map<String, Object> notificationExtras = new HashMap<String, Object>();
|
public static Map<String, Object> notificationExtras = new HashMap<String, Object>();
|
||||||
@ -106,7 +106,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
public void onPause(boolean multitasking) {
|
public void onPause(boolean multitasking) {
|
||||||
Log.i(TAG, "---------------- onPause");
|
Log.i(TAG, "---------------- onPause");
|
||||||
shouldCacheMsg = true;
|
shouldCacheMsg = true;
|
||||||
if (isStatisticsOpened) {
|
if (isStatisticsOpened && multitasking) {
|
||||||
JPushInterface.onPause(cordovaActivity);
|
JPushInterface.onPause(cordovaActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
Log.i(TAG, "---------------- onResume" + "-"
|
Log.i(TAG, "---------------- onResume" + "-"
|
||||||
+ JPushPlugin.openNotificationAlert + "-"
|
+ JPushPlugin.openNotificationAlert + "-"
|
||||||
+ JPushPlugin.notificationAlert);
|
+ JPushPlugin.notificationAlert);
|
||||||
if (isStatisticsOpened) {
|
if (isStatisticsOpened && multitasking) {
|
||||||
JPushInterface.onResume(cordovaActivity);
|
JPushInterface.onResume(cordovaActivity);
|
||||||
}
|
}
|
||||||
if (JPushPlugin.openNotificationAlert != null) {
|
if (JPushPlugin.openNotificationAlert != null) {
|
||||||
|
@ -9,30 +9,20 @@
|
|||||||
#import "AppDelegate+JPush.h"
|
#import "AppDelegate+JPush.h"
|
||||||
#import "JPushPlugin.h"
|
#import "JPushPlugin.h"
|
||||||
#import "JPUSHService.h"
|
#import "JPUSHService.h"
|
||||||
#import <objc/runtime.h>
|
|
||||||
|
|
||||||
@implementation AppDelegate (JPush)
|
@implementation AppDelegate (JPush)
|
||||||
|
|
||||||
+(void)load{
|
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||||
Method origin;
|
[JPushPlugin setLaunchOptions:launchOptions];
|
||||||
Method swizzle;
|
|
||||||
origin=class_getInstanceMethod([self class],@selector(init));
|
|
||||||
swizzle=class_getInstanceMethod([self class], @selector(init_plus));
|
|
||||||
method_exchangeImplementations(origin, swizzle);
|
|
||||||
}
|
|
||||||
|
|
||||||
-(instancetype)init_plus{
|
//cordova didFinishLaunchingWithOptions
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||||
selector:@selector(applicationDidLaunch:)
|
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
|
||||||
name:@"UIApplicationDidFinishLaunchingNotification"
|
self.viewController = [[CDVViewController alloc] init];
|
||||||
object:nil];
|
self.window.rootViewController = self.viewController;
|
||||||
return [self init_plus];
|
self.window.autoresizesSubviews = YES;
|
||||||
}
|
[self.window makeKeyAndVisible];
|
||||||
|
return YES;
|
||||||
-(void)applicationDidLaunch:(NSNotification*)notification{
|
|
||||||
if (notification) {
|
|
||||||
[JPushPlugin setLaunchOptions:notification.userInfo];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||||||
|
Loading…
Reference in New Issue
Block a user