mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-01-28 00:00:03 +08:00
5.9.0: android 5.9.0 ios:5.9.0
This commit is contained in:
1
.npmignore
Normal file
1
.npmignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cursor.md
|
||||||
32
cursor.md
Normal file
32
cursor.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
使用方法:修改需求里的内容,将需求和步骤内容作为指令让cursor进行执行。
|
||||||
|
|
||||||
|
|
||||||
|
需求:
|
||||||
|
1. 更新iOS JPush SDK 到 x.x.x 版本, JPush SDK 包的路径是:xxx
|
||||||
|
2. 更新Android JPush SDK 到 x.x.x 版本, JPush SDK 包的路径是:xxx
|
||||||
|
3. 将原生iOS、Android SDK 新增的方法,封装在插件中。
|
||||||
|
原生SDK新增方法一:
|
||||||
|
iOS:
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
|
Android:
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
|
统一封装为 方法名为 "" 的对外方法。
|
||||||
|
|
||||||
|
|
||||||
|
请按照以下步骤完成:
|
||||||
|
|
||||||
|
1. 找到需要升级的iOS JPush SDK,替换src/ios/jpush-ios-x.x.x.xcframework 为需要更新的版本。
|
||||||
|
2. 将plugin.xml中关于jpush-ios-x.x.x.xcframework相关的引用,替换为需要更新的版本。
|
||||||
|
3. 找到需要升级的Android JPush SDK,替换src/android/jpush-android-x.x.x.jar 为需要更新的版本。
|
||||||
|
4. 将plugin.xml中关于jpush-android-x.x.x.jar相关的引用,替换为需要更新的版本。
|
||||||
|
5. 封装新增的方法。(如果没有新增的方法就不用执行这一步)
|
||||||
|
6. 在plugin.xml中更新插件版本号,使用安卓SDK包的版本号。
|
||||||
|
7. 在package.json中更新插件版本号,使用安卓SDK包的版本号。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -586,6 +586,27 @@ document.addEventListener("jpush.receiveMessage", function (event) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 获取通知点击的参数 (Android only)
|
||||||
|
|
||||||
|
### event - jpush.receiveNotifyButtonClick
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
- 在你需要接收通知的的 js 文件中加入:
|
||||||
|
|
||||||
|
```js
|
||||||
|
document.addEventListener("jpush.receiveNotifyButtonClick", function (event) {
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
var msgId = event.msgId;
|
||||||
|
var platform = event.platform;
|
||||||
|
var name = event.name;
|
||||||
|
var actionType = event.actionType;
|
||||||
|
var action = event.action;
|
||||||
|
var data = event.data;
|
||||||
|
}
|
||||||
|
}, false)
|
||||||
|
```
|
||||||
|
|
||||||
## 判断系统设置中是否允许当前应用推送
|
## 判断系统设置中是否允许当前应用推送
|
||||||
### API - getUserNotificationSettings
|
### API - getUserNotificationSettings
|
||||||
判断系统设置中是否允许当前应用推送。
|
判断系统设置中是否允许当前应用推送。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "5.8.0",
|
"version": "5.9.0",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="jpush-phonegap-plugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="5.8.0">
|
version="5.9.0">
|
||||||
|
|
||||||
<name>JPush</name>
|
<name>JPush</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<header-file src="src/ios/Plugins/AppDelegate+JPush.h" />
|
<header-file src="src/ios/Plugins/AppDelegate+JPush.h" />
|
||||||
<source-file src="src/ios/Plugins/AppDelegate+JPush.m" />
|
<source-file src="src/ios/Plugins/AppDelegate+JPush.m" />
|
||||||
|
|
||||||
<source-file src="src/ios/lib/jpush-ios-5.7.0.xcframework" framework="true" />
|
<source-file src="src/ios/lib/jpush-ios-5.9.0.xcframework" framework="true" />
|
||||||
<resource-file src="src/ios/JPushConfig.plist" />
|
<resource-file src="src/ios/JPushConfig.plist" />
|
||||||
|
|
||||||
<framework src="CFNetwork.framework" weak="true" />
|
<framework src="CFNetwork.framework" weak="true" />
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
android:writePermission="${applicationId}.permission.JPUSH_MESSAGE" />
|
android:writePermission="${applicationId}.permission.JPUSH_MESSAGE" />
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<lib-file src="src/android/libs/jpush-android-5.8.0.jar" />
|
<lib-file src="src/android/libs/jpush-android-5.9.0.jar" />
|
||||||
|
|
||||||
<source-file src="src/android/PushService.java" target-dir="src/cn/jiguang/cordova/push" />
|
<source-file src="src/android/PushService.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||||
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />
|
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import cn.jpush.android.api.CustomMessage;
|
|||||||
import cn.jpush.android.api.JPushInterface;
|
import cn.jpush.android.api.JPushInterface;
|
||||||
import cn.jpush.android.api.JPushMessage;
|
import cn.jpush.android.api.JPushMessage;
|
||||||
import cn.jpush.android.api.NotificationMessage;
|
import cn.jpush.android.api.NotificationMessage;
|
||||||
|
import cn.jpush.android.api.NotificationCustomButton;
|
||||||
import cn.jpush.android.helper.Logger;
|
import cn.jpush.android.helper.Logger;
|
||||||
import cn.jpush.android.local.JPushConstants;
|
import cn.jpush.android.local.JPushConstants;
|
||||||
import cn.jpush.android.service.JPushMessageReceiver;
|
import cn.jpush.android.service.JPushMessageReceiver;
|
||||||
@@ -231,6 +232,23 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotifyButtonClick(Context context, NotificationCustomButton notificationCustomButton) {
|
||||||
|
cn.jiguang.cordova.push.JLogger.d(TAG, "[onNotifyButtonClick], " + notificationCustomButton.toString());
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("msgId", notificationCustomButton.a);
|
||||||
|
jsonObject.put("platform", notificationCustomButton.b);
|
||||||
|
jsonObject.put("name", notificationCustomButton.c);
|
||||||
|
jsonObject.put("actionType", notificationCustomButton.d);
|
||||||
|
jsonObject.put("action", notificationCustomButton.e);
|
||||||
|
jsonObject.put("data", notificationCustomButton.f);
|
||||||
|
cn.jiguang.cordova.push.JPushPlugin.transmitNotifyButtonClick(jsonObject);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
cn.jiguang.cordova.push.JLogger.d(TAG, "[onNotifyButtonClick] throwable:" + throwable);
|
||||||
|
}
|
||||||
|
}
|
||||||
interface SuccessCallback{
|
interface SuccessCallback{
|
||||||
void onSuccessCallback(JSONObject resultJson) throws JSONException;
|
void onSuccessCallback(JSONObject resultJson) throws JSONException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,6 +197,20 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void transmitNotifyButtonClick( JSONObject data) {
|
||||||
|
if (instance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String format = "window.plugins.jPushPlugin.receiveNotifyButtonClickCallback(%s);";
|
||||||
|
final String js = String.format(format, data.toString());
|
||||||
|
cordovaActivity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
instance.webView.loadUrl("javascript:" + js);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void transmitNotificationOpen(JSONObject data) {
|
static void transmitNotificationOpen(JSONObject data) {
|
||||||
|
|||||||
Binary file not shown.
@@ -76,10 +76,14 @@ static NSMutableDictionary *_jpushEventCache;
|
|||||||
// 设置手机号
|
// 设置手机号
|
||||||
-(void)setMobileNumber:(CDVInvokedUrlCommand*)command;
|
-(void)setMobileNumber:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
// 设置进入后台是否允许长连接 (iOS 5.9.0+)
|
||||||
|
-(void)setBackgroundEnable:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 以下为js中可监听到的事件
|
* 以下为js中可监听到的事件
|
||||||
* jpush.openNotification 点击推送消息启动或唤醒app
|
* jpush.openNotification 点击推送消息启动或唤醒app
|
||||||
* jpush.receiveMessage 收到自定义消息
|
* jpush.receiveMessage 收到自定义消息
|
||||||
|
* jpush.receiveNotifyButtonClick 收到通知栏自定义按钮点击事件
|
||||||
* jpush.receiveNotification 前台收到推送
|
* jpush.receiveNotification 前台收到推送
|
||||||
* jpush.backgroundNotification 后台收到推送
|
* jpush.backgroundNotification 后台收到推送
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -533,6 +533,12 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - 设置进入后台是否允许长连接 (iOS 5.9.0+)
|
||||||
|
-(void)setBackgroundEnable:(CDVInvokedUrlCommand *)command {
|
||||||
|
NSNumber* isEnable = [command argumentAtIndex:0];
|
||||||
|
[JPUSHService setBackgroundEnable:[isEnable boolValue]];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - 内部方法
|
#pragma mark - 内部方法
|
||||||
|
|
||||||
+(void)setupJPushSDK:(NSDictionary*)userInfo{
|
+(void)setupJPushSDK:(NSDictionary*)userInfo{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
|
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPUSH_VERSION_NUMBER 5.7.0
|
#define JPUSH_VERSION_NUMBER 5.9.0
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@@ -822,6 +822,16 @@ typedef NS_ENUM(NSUInteger, JPAuthorizationStatus) {
|
|||||||
*/
|
*/
|
||||||
+ (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion;
|
+ (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @abstract 设置进入后台是否允许长连接
|
||||||
|
*
|
||||||
|
* @param isEnable YES:允许,NO:不允许,默认是NO,进入后台会关闭长连接,回到前台会重新接入。
|
||||||
|
*
|
||||||
|
* @discussion 请在初始化函数之前调用
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
+ (void)setBackgroundEnable:(BOOL)isEnable;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 设置用户分群推送功能开关
|
* @abstract 设置用户分群推送功能开关
|
||||||
*
|
*
|
||||||
Binary file not shown.
@@ -9,7 +9,7 @@
|
|||||||
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
|
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPUSH_VERSION_NUMBER 5.7.0
|
#define JPUSH_VERSION_NUMBER 5.9.0
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@@ -822,6 +822,16 @@ typedef NS_ENUM(NSUInteger, JPAuthorizationStatus) {
|
|||||||
*/
|
*/
|
||||||
+ (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion;
|
+ (void)setPushEnable:(BOOL)isEnable completion:(nullable void (^)(NSInteger iResCode))completion;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @abstract 设置进入后台是否允许长连接
|
||||||
|
*
|
||||||
|
* @param isEnable YES:允许,NO:不允许,默认是NO,进入后台会关闭长连接,回到前台会重新接入。
|
||||||
|
*
|
||||||
|
* @discussion 请在初始化函数之前调用
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
+ (void)setBackgroundEnable:(BOOL)isEnable;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 设置用户分群推送功能开关
|
* @abstract 设置用户分群推送功能开关
|
||||||
*
|
*
|
||||||
Binary file not shown.
@@ -5,6 +5,7 @@ var JPushPlugin = function() {};
|
|||||||
JPushPlugin.prototype.receiveMessage = {};
|
JPushPlugin.prototype.receiveMessage = {};
|
||||||
JPushPlugin.prototype.openNotification = {};
|
JPushPlugin.prototype.openNotification = {};
|
||||||
JPushPlugin.prototype.receiveNotification = {};
|
JPushPlugin.prototype.receiveNotification = {};
|
||||||
|
JPushPlugin.prototype.notifyButtonClick = {};
|
||||||
|
|
||||||
JPushPlugin.prototype.isPlatformIOS = function() {
|
JPushPlugin.prototype.isPlatformIOS = function() {
|
||||||
return (
|
return (
|
||||||
@@ -390,6 +391,14 @@ JPushPlugin.prototype.receiveInAppMessageShowCallback = function(data) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JPushPlugin.prototype.receiveNotifyButtonClickCallback = function(data) {
|
||||||
|
if (device.platform === "Android") {
|
||||||
|
data = JSON.stringify(data);
|
||||||
|
this.notifyButtonClick = JSON.parse(data);
|
||||||
|
cordova.fireDocumentEvent("jpush.receiveNotifyButtonClick", this.notifyButtonClick);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
|
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
|
||||||
data = JSON.stringify(data);
|
data = JSON.stringify(data);
|
||||||
this.openNotification = JSON.parse(data);
|
this.openNotification = JSON.parse(data);
|
||||||
@@ -523,6 +532,17 @@ JPushPlugin.prototype.setAuth = function(isAuth){
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置进入后台是否允许长连接 (iOS 5.9.0+)
|
||||||
|
*
|
||||||
|
* @param isEnable boolean 是否允许长连接
|
||||||
|
*/
|
||||||
|
JPushPlugin.prototype.setBackgroundEnable = function(isEnable) {
|
||||||
|
if (this.isPlatformIOS()) {
|
||||||
|
this.callNative("setBackgroundEnable", [isEnable], null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (!window.plugins) {
|
if (!window.plugins) {
|
||||||
window.plugins = {};
|
window.plugins = {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user