mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-05-27 00:00:12 +08:00
iOS 更新到6.0.0,安卓更新到6.0.1版本。iOS SDK 换成cocoapods集成,安卓 SDK换成marven集成。插件版本改成6.0.1
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
# 更新 SDK
|
||||
|
||||
根据**输入的需要更新的 SDK 版本号**,同时更新本插件的 **iOS** 与 **Android** 依赖。本插件 Android 使用 Maven 集成、iOS 使用 CocoaPods 集成,无需下载或替换本地 SDK 包,只需在 `plugin.xml` 中修改两端的依赖版本号。
|
||||
|
||||
## 输入
|
||||
|
||||
执行本命令时请提供**目标 SDK 版本号**(如 `5.9.1`、`6.0.0`)。该版本号将用于:
|
||||
- **iOS**:CocoaPods 的 JPush pod 版本(`plugin.xml` 中的 `spec`)
|
||||
- **Android**:Maven 的 `cn.jiguang.sdk:jpush` 版本(`plugin.xml` 中的 `framework src`)
|
||||
|
||||
若 iOS 与 Android 官方发布的版本号不一致,请分别说明「iOS 目标版本」与「Android 目标版本」。
|
||||
|
||||
## 更新步骤
|
||||
|
||||
### 1. 更新 iOS SDK 版本(CocoaPods)
|
||||
|
||||
根据输入的版本号,在 `plugin.xml` 的 iOS 平台下修改 `<pod name="JPush" spec="..." />` 中的版本号。
|
||||
|
||||
**位置**:约第 51–55 行,`<podspec><pods>` 内。
|
||||
|
||||
**示例**:
|
||||
```xml
|
||||
<!-- 固定版本,如 6.0.0、6.0.1 -->
|
||||
<pod name="JPush" spec="6.0.0" />
|
||||
```
|
||||
|
||||
**说明**:CocoaPods 上 JPush 官方 pod 的版本以 [CocoaPods JPush](https://cocoapods.org/pods/jpush) 为准。修改后执行 `cordova build ios` 或进入 `platforms/ios` 执行 `pod install` 即可拉取对应版本。
|
||||
|
||||
### 2. 更新 Android SDK 版本(Maven)
|
||||
|
||||
根据输入的版本号,在 `plugin.xml` 的 Android 平台下修改 `<framework src="cn.jiguang.sdk:jpush:x.x.x" />` 中的版本号。
|
||||
|
||||
**位置**:约第 252–253 行。
|
||||
|
||||
**示例**:
|
||||
```xml
|
||||
<!-- 更新为 5.9.1 -->
|
||||
<framework src="cn.jiguang.sdk:jpush:5.9.1" />
|
||||
```
|
||||
|
||||
**说明**:依赖从 Maven Central 拉取,无需替换本地 jar。修改后执行 `cordova build android` 即可使用新版本。
|
||||
|
||||
### 3. 查找 SDK 新增 API
|
||||
|
||||
**⚠️ 重要:必须逐项查看更新日志,不要因为看到「更新各厂商 SDK」等描述就跳过新增 API 的检查。**
|
||||
|
||||
执行本步时按文末「文档内容获取方式」获取下方更新日志页面的内容,逐条阅读,不要仅依赖网页搜索。
|
||||
|
||||
#### Android SDK
|
||||
- 访问 [极光推送 Android SDK 更新日志](https://docs.jiguang.cn/jpush/jpush_changelog/updates_Android) 查找目标版本的新增对外 API。
|
||||
- **检查方法**:
|
||||
1. 找到目标版本(如 5.9.0)的更新内容。
|
||||
2. **逐条阅读**每一条,不要跳过。
|
||||
3. 重点看包含「新增」「新增接口」「新增 API」「新增方法」或 Java 方法签名的条目。
|
||||
4. 对每个疑似新增 API,记录:方法名、完整方法签名、功能说明。
|
||||
- 在 [Android SDK API 文档](https://docs.jiguang.cn/jpush/client/Android/android_api) 中确认用法、参数和示例。
|
||||
|
||||
#### iOS SDK
|
||||
- 访问 [极光推送 iOS SDK 更新说明](https://docs.jiguang.cn/jpush/jpush_changelog/updates_iOS) 查找目标版本的新增对外 API。
|
||||
- **检查方法**:
|
||||
1. 找到目标版本的更新内容。
|
||||
2. **逐条阅读**每一条。
|
||||
3. 重点看包含「新增」「新增接口」「新增 API」或 Objective-C 方法签名的条目。
|
||||
4. 对每个疑似新增 API,记录:方法名、完整方法签名、功能说明。
|
||||
- 在 [iOS SDK API 文档](https://docs.jiguang.cn/jpush/client/iOS/ios_api) 中确认用法、参数和示例。
|
||||
|
||||
**检查清单**(完成后勾选):
|
||||
- [ ] 已找到目标版本的更新日志
|
||||
- [ ] 已逐条阅读所有更新内容(含次要更新)
|
||||
- [ ] 已识别所有含「新增」「API」「接口」「方法」等的条目
|
||||
- [ ] 已记录所有新增 API 的方法名和签名
|
||||
- [ ] 已在对应平台 API 文档中确认每个新增 API 的用法
|
||||
- [ ] 已区分「需在插件中封装的对外 API」与「仅内部实现、无需封装」的更新
|
||||
|
||||
**常见误区**:
|
||||
- ❌ 看到「更新各厂商 SDK」就认为没有新增 API → ✅ 仍要逐条检查
|
||||
- ❌ 只扫一眼主要更新 → ✅ 必须逐条检查
|
||||
- ❌ 靠搜索判断有没有新增 API → ✅ 以官方更新日志为准
|
||||
- ❌ 文档有缺字/错字时直接忽略 → ✅ 需到官方文档核实
|
||||
|
||||
### 4. 封装新增 API(如有)
|
||||
|
||||
**⚠️ 若无新增 API,需明确写「经检查,该版本无新增对外 API」,再跳过本步。**
|
||||
|
||||
若有新增 API,需在插件中封装:
|
||||
- 在 `www/JPushPlugin.js` 中增加 JavaScript 接口
|
||||
- 在 `src/android/JPushPlugin.java` 中实现 Android 逻辑
|
||||
- 在 `src/ios/Plugins/JPushPlugin.m` 或 `AppDelegate+JPush.m` 中实现 iOS 逻辑
|
||||
|
||||
**封装原则**:
|
||||
- Android 与 iOS 为同一功能时,封装为一个插件方法
|
||||
- 不同功能分别封装
|
||||
- **直接调用 SDK API,不要用反射**
|
||||
- 若无新增 API,**必须写明「已检查并确认无新增 API」后跳过**
|
||||
|
||||
**封装步骤**:
|
||||
1. 确认 API 的完整签名与参数类型
|
||||
2. 确认调用时机(是否需在 init 之前调用)
|
||||
3. 在对应平台实现
|
||||
4. 在 JS 层增加方法,风格与现有 API 一致
|
||||
5. 补充必要的错误处理与日志
|
||||
|
||||
### 5. 更新 API 文档
|
||||
|
||||
若新增了插件方法,需更新文档:
|
||||
- `doc/Common_detail_api.md`:通用或跨平台方法
|
||||
- `doc/Android_detail_api.md`:仅 Android 方法
|
||||
- `doc/iOS_API.md`:仅 iOS 方法
|
||||
|
||||
若无新增方法,跳过此步。
|
||||
|
||||
### 6. 在 example/index.html 中添加示例(若有新增 API)
|
||||
|
||||
**若有新增插件方法**,需在示例工程中增加可操作示例,便于开发者验证与参考:
|
||||
|
||||
- 在 `example/index.html` 中为每个新增 API 增加:
|
||||
1. **按钮**:在合适位置的 `<div data-role="fieldcontain">` 中增加 `<input type="button" id="xxx" value="Xxx" />`(id 与 API 含义对应)。
|
||||
2. **点击逻辑**:在 `initiateUI` 内用 `$("#xxx").click(...)` 调用 `window.JPush.新方法(...)`,在回调中用 `alert` 或 `$("#某结果区").html(...)` 展示结果。
|
||||
3. 若有结果展示,可复用已有结果区域或新增 `<label id="xxxResult">` 等。
|
||||
|
||||
风格与现有示例保持一致(如 setTags、getAlias、setMobileNumber 等),便于用户对照文档在真机/模拟器上点击验证。
|
||||
|
||||
若无新增方法,跳过此步。
|
||||
|
||||
### 7. 更新插件版本号
|
||||
|
||||
**⚠️ 重要:`plugin.xml` 与 `package.json` 中的版本号需一致。**
|
||||
|
||||
本插件版本号与 **Android SDK 版本号** 对齐(如 SDK 5.9.0 → 插件 5.9.0)。
|
||||
|
||||
- 在 `plugin.xml` 根节点 `version` 中更新版本号(约第 5 行)
|
||||
- 在 `package.json` 的 `version` 中更新为相同版本号
|
||||
|
||||
**示例**:
|
||||
- 当前插件版本:5.9.0,本次升级 Android SDK 到 5.9.1 → 插件版本改为 **5.9.1**
|
||||
- 若仅升级 CocoaPods 侧 JPush 版本、且希望插件版本与 Android 一致,可继续使用当前 Android SDK 版本作为插件版本
|
||||
|
||||
## 文档内容获取方式
|
||||
|
||||
文档中的链接(极光更新日志、API 文档、CocoaPods 等)需要获取内容时:用 **curl 拉取对应 URL**,在返回的 HTML 里用 **grep 或搜索** 定位所需段落(极光页面为服务端渲染,内容均在 HTML 中,无需执行 JS)。
|
||||
|
||||
## 注意事项
|
||||
|
||||
- **必须逐条检查更新日志,避免遗漏新增 API**
|
||||
- 确保 Android(Maven)与 iOS(CocoaPods)使用的 SDK 版本符合预期
|
||||
- 新增 API 的封装风格需与现有 API 一致
|
||||
- 更新后建议做一次完整构建与功能验证
|
||||
- **若更新日志有缺字、错字,以极光官方文档为准**
|
||||
- **`plugin.xml` 与 `package.json` 的版本号必须一致**
|
||||
- 本插件不包含本地 SDK 包,所有依赖通过 Maven(Android)和 CocoaPods(iOS)拉取
|
||||
@@ -1 +1,2 @@
|
||||
cursor.md
|
||||
.cursor/
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
>如果需要安装之前版本的插件,请先安装 v1.2.0 以下版本(建议安装 v1.1.12)的 [cordova-plugin-jcore](https://github.com/jpush/cordova-plugin-jcore),再安装旧版本插件(比如 v3.3.2),否则运行会报错。
|
||||
>
|
||||
>[Cordova Android版本与原生版本对应表](http://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#requirements-and-support)
|
||||
>
|
||||
>**集成方式说明**:Android 通过 Maven 拉取 `cn.jiguang.sdk:jpush`,iOS 通过 CocoaPods 拉取 `JPush` pod,无需再依赖插件内的本地 SDK 包。
|
||||
## Install
|
||||
|
||||
> 注意:
|
||||
@@ -32,6 +34,7 @@
|
||||
|
||||
- 或直接通过 url 安装:
|
||||
|
||||
|
||||
```shell
|
||||
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable APP_KEY=your_jpush_appkey
|
||||
```
|
||||
|
||||
@@ -20,13 +20,11 @@
|
||||
|
||||
请按照以下步骤完成:
|
||||
|
||||
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包的版本号。
|
||||
1. iOS 使用 CocoaPods 集成:在 plugin.xml 的 iOS 平台下修改 `<pod name="JPush" spec="x.x.x" />` 中的版本号(固定版本,如 6.0.0)即可。
|
||||
2. Android 使用 Maven 集成:在 plugin.xml 的 Android 平台下修改 `<framework src="cn.jiguang.sdk:jpush:x.x.x" />` 中的版本号即可。
|
||||
3. 封装新增的方法。(如果没有新增的方法就不用执行这一步)
|
||||
4. 在 plugin.xml 中更新插件版本号,使用安卓 SDK 包的版本号。
|
||||
5. 在 package.json 中更新插件版本号,使用安卓 SDK 包的版本号。
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- [stopPush](#stoppush)
|
||||
- [resumePush](#resumepush)
|
||||
- [isPushStopped](#ispushstopped)
|
||||
- [getPushStatus](#getpushstatus)
|
||||
- [开启 Debug 模式](#开启-debug-模式)
|
||||
- [setDebugMode](#setdebugmode)
|
||||
- [获取 RegistrationID](#获取-registrationid)
|
||||
@@ -131,6 +132,37 @@ window.JPush.isPushStopped(function (result) {
|
||||
})
|
||||
```
|
||||
|
||||
### getPushStatus
|
||||
|
||||
- **Android 6.0.0+ / iOS 6.0.0+**:推荐使用本接口替代 `isPushStopped`,用于检查推送是否被停止。
|
||||
- 回调结果为 `{ code: number, isStopped: 0|1 }`:`code` 为 0 表示成功,非 0 表示错误码;**`isStopped` 仅在 `code === 0` 时有效**(0 表示推送未停止,1 表示推送已停止),当 `code !== 0` 时请勿依赖 `isStopped` 做业务判断。
|
||||
|
||||
#### 接口定义
|
||||
|
||||
```js
|
||||
window.JPush.getPushStatus(callback)
|
||||
```
|
||||
|
||||
#### 参数说明
|
||||
|
||||
- callback: 回调函数,参数为 `(result)`,result 为 `{ code: number, isStopped: 0|1 }`。**注意:`isStopped` 仅在 `code === 0` 时有效。**
|
||||
|
||||
#### 代码示例
|
||||
|
||||
```js
|
||||
window.JPush.getPushStatus(function (result) {
|
||||
if (result.code !== 0) {
|
||||
// 获取状态失败,不解析 isStopped
|
||||
return;
|
||||
}
|
||||
if (result.isStopped === 0) {
|
||||
// 推送未停止
|
||||
} else if (result.isStopped === 1) {
|
||||
// 推送已停止
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 开启 Debug 模式
|
||||
### setDebugMode
|
||||
用于开启 Debug 模式,显示更多的日志信息。
|
||||
|
||||
@@ -210,6 +210,16 @@
|
||||
alert(error.code)
|
||||
})
|
||||
})
|
||||
|
||||
$("#getPushStatus").click(function (event) {
|
||||
window.JPush.getPushStatus(function (result) {
|
||||
var text = "code: " + result.code + ", isStopped: " + result.isStopped;
|
||||
if (result.code !== 0) {
|
||||
text += " (isStopped 仅当 code 为 0 时有效)";
|
||||
}
|
||||
$("#pushStatusResult").html(text);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
@@ -287,6 +297,10 @@
|
||||
<input type="button" id="setMobileNumber" value="Set mobileNumber" />
|
||||
</div>
|
||||
|
||||
<div data-role="fieldcontain">
|
||||
<input type="button" id="getPushStatus" value="Get push status" />
|
||||
</div>
|
||||
|
||||
<div data-role="fieldcontain">
|
||||
<label id="tagsPrompt">设置 Tag 的结果:</label>
|
||||
<label id="tagsResult">null</label>
|
||||
@@ -299,6 +313,10 @@
|
||||
<label id="mobileNumberPrompt">设置手机号的结果:</label>
|
||||
<label id="mobileNumberResult">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="pushStatusPrompt">Get push status 结果 (code=0 成功, isStopped 仅当 code 为 0 时有效):</label>
|
||||
<label id="pushStatusResult">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="notificationPrompt">接受的通知内容:</label>
|
||||
<label id="notificationResult">null</label>
|
||||
|
||||
@@ -47,6 +47,9 @@ export class JPush extends IonicNativePlugin {
|
||||
@Cordova()
|
||||
isPushStopped(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
getPushStatus(): Promise<{ code: number; isStopped: 0 | 1 }> { return; }
|
||||
|
||||
@Cordova()
|
||||
setTags(params: TagOptions): Promise<any> { return; }
|
||||
|
||||
|
||||
Vendored
+2
@@ -42,6 +42,8 @@ export declare class JPushOriginal extends IonicNativePlugin {
|
||||
stopPush(): Promise<any>;
|
||||
resumePush(): Promise<any>;
|
||||
isPushStopped(): Promise<any>;
|
||||
/** 检查推送是否被停止(SDK 6.0+ 推荐),返回 { code: number, isStopped: 0|1 }。isStopped 仅在 code 为 0 时有效 */
|
||||
getPushStatus(): Promise<{ code: number; isStopped: 0 | 1 }>;
|
||||
setTags(params: TagOptions): Promise<any>;
|
||||
addTags(params: TagOptions): Promise<any>;
|
||||
deleteTags(params: TagOptions): Promise<any>;
|
||||
|
||||
@@ -24,6 +24,7 @@ var JPushOriginal = /** @class */ (function (_super) {
|
||||
JPushOriginal.prototype.stopPush = function () { return cordova(this, "stopPush", {}, arguments); };
|
||||
JPushOriginal.prototype.resumePush = function () { return cordova(this, "resumePush", {}, arguments); };
|
||||
JPushOriginal.prototype.isPushStopped = function () { return cordova(this, "isPushStopped", {}, arguments); };
|
||||
JPushOriginal.prototype.getPushStatus = function () { return cordova(this, "getPushStatus", {}, arguments); };
|
||||
JPushOriginal.prototype.setTags = function (params) { return cordova(this, "setTags", {}, arguments); };
|
||||
JPushOriginal.prototype.addTags = function (params) { return cordova(this, "addTags", {}, arguments); };
|
||||
JPushOriginal.prototype.deleteTags = function (params) { return cordova(this, "deleteTags", {}, arguments); };
|
||||
|
||||
Vendored
+2
@@ -42,6 +42,8 @@ export declare class JPush extends IonicNativePlugin {
|
||||
stopPush(): Promise<any>;
|
||||
resumePush(): Promise<any>;
|
||||
isPushStopped(): Promise<any>;
|
||||
/** isStopped 仅在 code 为 0 时有效 */
|
||||
getPushStatus(): Promise<{ code: number; isStopped: 0 | 1 }>;
|
||||
setTags(params: TagOptions): Promise<any>;
|
||||
addTags(params: TagOptions): Promise<any>;
|
||||
deleteTags(params: TagOptions): Promise<any>;
|
||||
|
||||
@@ -42,6 +42,7 @@ var JPush = /** @class */ (function (_super) {
|
||||
JPush.prototype.stopPush = function () { return cordova(this, "stopPush", {}, arguments); };
|
||||
JPush.prototype.resumePush = function () { return cordova(this, "resumePush", {}, arguments); };
|
||||
JPush.prototype.isPushStopped = function () { return cordova(this, "isPushStopped", {}, arguments); };
|
||||
JPush.prototype.getPushStatus = function () { return cordova(this, "getPushStatus", {}, arguments); };
|
||||
JPush.prototype.setTags = function (params) { return cordova(this, "setTags", {}, arguments); };
|
||||
JPush.prototype.addTags = function (params) { return cordova(this, "addTags", {}, arguments); };
|
||||
JPush.prototype.deleteTags = function (params) { return cordova(this, "deleteTags", {}, arguments); };
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jpush-phonegap-plugin",
|
||||
"version": "5.9.0",
|
||||
"version": "6.0.1",
|
||||
"description": "JPush for cordova plugin",
|
||||
"cordova": {
|
||||
"id": "jpush-phonegap-plugin",
|
||||
|
||||
+19
-87
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
id="jpush-phonegap-plugin"
|
||||
version="5.9.0">
|
||||
version="6.0.1">
|
||||
|
||||
<name>JPush</name>
|
||||
<description>JPush for cordova plugin</description>
|
||||
@@ -48,7 +49,12 @@
|
||||
<header-file src="src/ios/Plugins/AppDelegate+JPush.h" />
|
||||
<source-file src="src/ios/Plugins/AppDelegate+JPush.m" />
|
||||
|
||||
<source-file src="src/ios/lib/jpush-ios-5.9.0.xcframework" framework="true" />
|
||||
<!-- JPush SDK 通过 CocoaPods 集成 -->
|
||||
<podspec>
|
||||
<pods>
|
||||
<pod name="JPush" spec="6.0.0" />
|
||||
</pods>
|
||||
</podspec>
|
||||
<resource-file src="src/ios/JPushConfig.plist" />
|
||||
|
||||
<framework src="CFNetwork.framework" weak="true" />
|
||||
@@ -72,6 +78,11 @@
|
||||
</platform>
|
||||
|
||||
<platform name="android">
|
||||
<!-- aar 合并时与 cn.jiguang.sdk:jpush 的 meta-data 冲突,需声明 tools 并用 tools:replace 覆盖 -->
|
||||
<edit-config file="AndroidManifest.xml" target="/manifest" mode="merge">
|
||||
<manifest xmlns:tools="http://schemas.android.com/tools" />
|
||||
</edit-config>
|
||||
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="JPushPlugin">
|
||||
<param name="android-package" value="cn.jiguang.cordova.push.JPushPlugin" />
|
||||
@@ -113,58 +124,6 @@
|
||||
|
||||
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
||||
|
||||
|
||||
<!-- Rich push 核心功能 since 2.0.6-->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PopWinActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/JPushDialogStyle" >
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<action android:name="cn.jpush.android.ui.PopWinActivity" />
|
||||
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<activity
|
||||
android:name="cn.jpush.android.ui.PushActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:theme="@android:style/Theme.NoTitleBar"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.ui.PushActivity" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
|
||||
<!-- since 3.0.9 Required SDK 核心功能-->
|
||||
<provider
|
||||
android:authorities="$PACKAGE_NAME.DataProvider"
|
||||
android:name="cn.jpush.android.service.DataProvider"
|
||||
android:process=":pushcore"
|
||||
android:exported="false"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<receiver
|
||||
android:name="cn.jpush.android.service.PushReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!--Required 显示通知栏 -->
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
|
||||
<!-- 3.5.0新增,用于定时展示功能 -->
|
||||
<receiver android:name="cn.jpush.android.service.SchedulerReceiver" android:exported="false"/>
|
||||
@@ -178,35 +137,7 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!--since 3.3.0 Required SDK核心功能-->
|
||||
|
||||
<!-- since 3.3.0 Required SDK核心功能 -->
|
||||
<activity
|
||||
android:name="cn.jpush.android.service.JNotifyActivity"
|
||||
android:exported="true"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/JPushTheme" >
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.JNotifyActivity" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- since 4.6.0 Required SDK核心功能 -->
|
||||
<activity
|
||||
android:name="cn.android.service.JTransitActivity"
|
||||
android:exported="true"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/JPushTheme" >
|
||||
<intent-filter>
|
||||
<action android:name="cn.android.service.JTransitActivity" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
<!-- since 3.3.0 Required SDK 核心功能-->
|
||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||
<!--User defined. For test only 继承自cn.jpush.android.service.JCommonService-->
|
||||
@@ -233,9 +164,9 @@
|
||||
<!-- </intent-filter>-->
|
||||
</receiver>
|
||||
|
||||
<!-- Required . Enable it you can get statistics data with channel -->
|
||||
<meta-data android:name="JPUSH_CHANNEL" android:value="$CHANNEL"/>
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" /> <!-- </>值来自开发者平台取得的AppKey-->
|
||||
<!-- Required:SDK 从合并后的 AndroidManifest 读取。aar 内也有同名 meta-data,用 tools:replace 覆盖占位符 -->
|
||||
<meta-data android:name="JPUSH_CHANNEL" android:value="$CHANNEL" tools:replace="android:value" />
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" tools:replace="android:value" />
|
||||
<provider
|
||||
android:name="cn.jpush.android.service.InitProvider"
|
||||
android:authorities="${applicationId}.jiguang.InitProvider"
|
||||
@@ -244,7 +175,8 @@
|
||||
android:writePermission="${applicationId}.permission.JPUSH_MESSAGE" />
|
||||
</config-file>
|
||||
|
||||
<lib-file src="src/android/libs/jpush-android-5.9.0.jar" />
|
||||
<!-- JPush SDK 通过 Maven 集成,替代本地 jar -->
|
||||
<framework src="cn.jiguang.sdk:jpush:6.0.1" />
|
||||
|
||||
<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" />
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import cn.jpush.android.api.CmdMessage;
|
||||
import cn.jpush.android.api.CustomMessage;
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.JPushMessage;
|
||||
@@ -86,6 +87,17 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
||||
cn.jiguang.cordova.push.JPushPlugin.transmitReceiveRegistrationId(regId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandResult(Context context, CmdMessage cmdMessage) {
|
||||
super.onCommandResult(context, cmdMessage);
|
||||
if (cmdMessage == null) return;
|
||||
// cmd 2003: getPushStatus / isPushStopped 状态回调。errorCode: 0=未停止, 1=已停止, 其他=异常
|
||||
if (cmdMessage.cmd == 2003) {
|
||||
cn.jiguang.cordova.push.JLogger.d(TAG, "[onCommandResult] getPushStatus, errorCode=" + cmdMessage.errorCode);
|
||||
cn.jiguang.cordova.push.JPushPlugin.onGetPushStatusResult(cmdMessage.errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Context context, CustomMessage customMessage) {
|
||||
// super.onMessage(context,customMessage);
|
||||
|
||||
@@ -50,6 +50,9 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
|
||||
static Map<Integer, CallbackContext> eventCallbackMap = new HashMap<Integer, CallbackContext>();
|
||||
|
||||
/** getPushStatus 异步结果通过 JPushMessageReceiver.onCommandResult(cmd==2003) 回调,此处暂存 CallbackContext */
|
||||
static CallbackContext getPushStatusCallbackContext;
|
||||
|
||||
public JPushPlugin() {
|
||||
instance = this;
|
||||
}
|
||||
@@ -329,6 +332,35 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
void getPushStatus(JSONArray data, CallbackContext callbackContext) {
|
||||
getPushStatusCallbackContext = callbackContext;
|
||||
JPushInterface.getPushStatus(mContext);
|
||||
// 结果在 JPushEventReceiver.onCommandResult 中当 cmd==2003 时回调
|
||||
}
|
||||
|
||||
/**
|
||||
* 由 JPushEventReceiver.onCommandResult 在 cmd==2003 时调用,传递 getPushStatus 异步结果。
|
||||
* 与 iOS 对齐:code=0 表示成功,非 0 表示错误码;isStopped=0 未停止,1 已停止。
|
||||
* Android errorCode: 0=未停止, 1=已停止, 其他=异常。
|
||||
*/
|
||||
static void onGetPushStatusResult(int errorCode) {
|
||||
if (getPushStatusCallbackContext == null) return;
|
||||
try {
|
||||
JSONObject result = new JSONObject();
|
||||
if (errorCode == 0 || errorCode == 1) {
|
||||
result.put("code", 0);
|
||||
result.put("isStopped", errorCode == 1 ? 1 : 0);
|
||||
} else {
|
||||
result.put("code", errorCode);
|
||||
result.put("isStopped", 0);
|
||||
}
|
||||
getPushStatusCallbackContext.success(result);
|
||||
} catch (JSONException e) {
|
||||
getPushStatusCallbackContext.error("getPushStatus result error");
|
||||
}
|
||||
getPushStatusCallbackContext = null;
|
||||
}
|
||||
|
||||
void areNotificationEnabled(JSONArray data, final CallbackContext callback) {
|
||||
int isEnabled;
|
||||
if (hasPermission("OP_POST_NOTIFICATION")) {
|
||||
|
||||
Binary file not shown.
@@ -52,6 +52,8 @@ static NSMutableDictionary *_jpushEventCache;
|
||||
-(void)stopPush:(CDVInvokedUrlCommand*)command;
|
||||
-(void)resumePush:(CDVInvokedUrlCommand*)command;
|
||||
-(void)isPushStopped:(CDVInvokedUrlCommand*)command;
|
||||
// 检查推送是否被停止(iOS 6.0.0+ 推荐,替代 isPushStopped)
|
||||
-(void)getPushStatus:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//开关日志
|
||||
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@@ -48,6 +48,18 @@
|
||||
[self handleResultWithValue:result command:command];
|
||||
}
|
||||
|
||||
-(void)getPushStatus:(CDVInvokedUrlCommand*)command{
|
||||
WEAK_SELF(weakSelf)
|
||||
[JPUSHService getPushStatus:^(NSInteger iResCode, BOOL isStopped) {
|
||||
NSDictionary *result = @{
|
||||
@"code": @(iResCode),
|
||||
@"isStopped": isStopped ? @1 : @0
|
||||
};
|
||||
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:result];
|
||||
[weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)initial:(CDVInvokedUrlCommand*)command{
|
||||
//do nithng,because Cordova plugin use lazy load mode.
|
||||
}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?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>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libJPush.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libJPush.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,23 +0,0 @@
|
||||
<?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>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>CA92.1</string>
|
||||
</array>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
-1011
File diff suppressed because it is too large
Load Diff
-23
@@ -1,23 +0,0 @@
|
||||
<?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>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypeReasons</key>
|
||||
<array>
|
||||
<string>CA92.1</string>
|
||||
</array>
|
||||
<key>NSPrivacyAccessedAPIType</key>
|
||||
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@@ -82,6 +82,14 @@ JPushPlugin.prototype.isPushStopped = function(successCallback) {
|
||||
this.callNative("isPushStopped", [], successCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* 检查推送是否被停止(推荐,SDK 6.0+ 新增接口,替代 isPushStopped)
|
||||
* @param successCallback 回调 (result) => {},result 为 { code: number, isStopped: 0|1 },code 为 0 表示成功,isStopped 为 1 表示已停止
|
||||
*/
|
||||
JPushPlugin.prototype.getPushStatus = function(successCallback) {
|
||||
this.callNative("getPushStatus", [], successCallback);
|
||||
};
|
||||
|
||||
JPushPlugin.prototype.clearLocalNotifications = function() {
|
||||
if (device.platform === "Android") {
|
||||
this.callNative("clearLocalNotifications", [], null);
|
||||
|
||||
Reference in New Issue
Block a user