doopush-react-native-sdk 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/android/src/main/java/com/doopush/reactnative/DooPushReactNativeSDKModule.kt +3 -3
- package/package.json +10 -8
- package/plugin/build/android/withAndroid.js +2 -0
- package/plugin/build/android/withOppoManifest.d.ts +3 -0
- package/plugin/build/android/withOppoManifest.js +61 -0
package/README.md
CHANGED
|
@@ -181,6 +181,11 @@ MIT
|
|
|
181
181
|
|
|
182
182
|
## CHANGELOG
|
|
183
183
|
|
|
184
|
+
### v0.5.2
|
|
185
|
+
- **Fix (config plugin)**:OPPO 注册静默超时(拿不到 RegisterId),因为构建产物缺少 HeyTap MCS 所需的 manifest 声明;新增 `withDooPushOppoManifest`,启用 `oppo` 厂商时注入两条 `RECIEVE_MCS_MESSAGE` 权限与 `CompatibleDataMessageCallbackService` / `DataMessageCallbackService` 回调服务。
|
|
186
|
+
- **Fix (Android)**:注册失败事件(`onRegisterError` / `register` reject)透出厂商返回的真实错误信息,替换此前的通用 "register failed"。
|
|
187
|
+
- **Docs**:更正 OPPO 集成说明,此前错误标注"无需额外配置"。
|
|
188
|
+
|
|
184
189
|
### v0.5.1
|
|
185
190
|
- **Fix (Android)**:`expo prebuild` 流程缺失 `google-services` Gradle 插件 classpath 注入,原生工程 sync 失败;config plugin 现在补齐 `withRootBuildGradle` / `withSettingsGradle` / `withGradleProperties`,prebuild 全流程跑通。
|
|
186
191
|
- **Fix (config plugin)**:`zod` 等 plugin 运行时依赖错误地放在 `devDependencies` 里,用户 `npx expo prebuild` 时 plugin 解析失败;改为生产依赖。
|
|
@@ -80,7 +80,7 @@ class DooPushReactNativeSDKModule : Module(), DooPushCallback {
|
|
|
80
80
|
))
|
|
81
81
|
}
|
|
82
82
|
override fun onError(error: DooPushError) {
|
|
83
|
-
promise.reject("E_REGISTER", error.
|
|
83
|
+
promise.reject("E_REGISTER", error.getFullDescription(), error)
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
)
|
|
@@ -99,7 +99,7 @@ class DooPushReactNativeSDKModule : Module(), DooPushCallback {
|
|
|
99
99
|
promise.resolve(mapOf("deviceId" to result.deviceId))
|
|
100
100
|
}
|
|
101
101
|
override fun onError(error: DooPushError) {
|
|
102
|
-
promise.reject("E_REGISTER", error.
|
|
102
|
+
promise.reject("E_REGISTER", error.getFullDescription(), error)
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
)
|
|
@@ -222,7 +222,7 @@ class DooPushReactNativeSDKModule : Module(), DooPushCallback {
|
|
|
222
222
|
override fun onRegisterError(error: DooPushError) {
|
|
223
223
|
sendEvent("onRegisterError", mapOf(
|
|
224
224
|
"code" to "E_REGISTER",
|
|
225
|
-
"message" to
|
|
225
|
+
"message" to error.getFullDescription()
|
|
226
226
|
))
|
|
227
227
|
}
|
|
228
228
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doopush-react-native-sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "React Native SDK for DooPush push notification service. Built with Expo Modules API; works in Expo (managed/prebuild) and bare RN.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"app.plugin.js",
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc && pnpm --filter ./plugin build",
|
|
18
|
+
"build:plugin": "tsc -p plugin/tsconfig.json",
|
|
19
|
+
"test": "pnpm --filter ./plugin test",
|
|
20
|
+
"clean": "rm -rf build plugin/build",
|
|
21
|
+
"prepare": "pnpm build",
|
|
22
|
+
"prepublishOnly": "pnpm clean && pnpm build && pnpm test"
|
|
23
|
+
},
|
|
16
24
|
"keywords": [
|
|
17
25
|
"react-native",
|
|
18
26
|
"expo",
|
|
@@ -41,11 +49,5 @@
|
|
|
41
49
|
"react": "18.2.0",
|
|
42
50
|
"react-native": "0.73.0",
|
|
43
51
|
"typescript": "^5.3.0"
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsc && pnpm --filter ./plugin build",
|
|
47
|
-
"build:plugin": "tsc -p plugin/tsconfig.json",
|
|
48
|
-
"test": "pnpm --filter ./plugin test",
|
|
49
|
-
"clean": "rm -rf build plugin/build"
|
|
50
52
|
}
|
|
51
|
-
}
|
|
53
|
+
}
|
|
@@ -6,12 +6,14 @@ const withSettingsGradle_1 = require("./withSettingsGradle");
|
|
|
6
6
|
const withAppBuildGradle_1 = require("./withAppBuildGradle");
|
|
7
7
|
const withGradleProperties_1 = require("./withGradleProperties");
|
|
8
8
|
const withGoogleServices_1 = require("./withGoogleServices");
|
|
9
|
+
const withOppoManifest_1 = require("./withOppoManifest");
|
|
9
10
|
const withAndroid = (config, validated) => {
|
|
10
11
|
config = (0, withSettingsGradle_1.withDooPushSettingsGradle)(config, validated);
|
|
11
12
|
config = (0, withGradleProperties_1.withDooPushGradleProperties)(config, validated);
|
|
12
13
|
config = (0, withRootBuildGradle_1.withDooPushRootBuildGradle)(config, validated);
|
|
13
14
|
config = (0, withAppBuildGradle_1.withDooPushAppBuildGradle)(config, validated);
|
|
14
15
|
config = (0, withGoogleServices_1.withDooPushGoogleServices)(config, validated);
|
|
16
|
+
config = (0, withOppoManifest_1.withDooPushOppoManifest)(config, validated);
|
|
15
17
|
return config;
|
|
16
18
|
};
|
|
17
19
|
exports.withAndroid = withAndroid;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withDooPushOppoManifest = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
/**
|
|
6
|
+
* HeyTap MCS(OPPO/ColorOS 推送)要求在 AndroidManifest 声明的权限与回调 service。
|
|
7
|
+
*
|
|
8
|
+
* umeng `oppo-push` 的 aar 自带 manifest 为空(只声明 package),不会贡献这些节点;
|
|
9
|
+
* 其余 vendor 的 aar 自带完整 manifest,所以只有 OPPO 需要 plugin 主动补。缺这些节点时,
|
|
10
|
+
* 系统推送服务收到注册后无处回传 RegisterId,DooPush.register() 会静默超时、拿不到 token。
|
|
11
|
+
*/
|
|
12
|
+
const MCS_PERMISSIONS = [
|
|
13
|
+
'com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE',
|
|
14
|
+
'com.heytap.mcs.permission.RECIEVE_MCS_MESSAGE',
|
|
15
|
+
];
|
|
16
|
+
const MCS_SERVICES = [
|
|
17
|
+
{
|
|
18
|
+
name: 'com.heytap.msp.push.service.CompatibleDataMessageCallbackService',
|
|
19
|
+
permission: 'com.coloros.mcs.permission.SEND_MCS_MESSAGE',
|
|
20
|
+
actions: ['com.coloros.mcs.action.RECEIVE_MCS_MESSAGE'],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'com.heytap.msp.push.service.DataMessageCallbackService',
|
|
24
|
+
permission: 'com.heytap.mcs.permission.SEND_PUSH_MESSAGE',
|
|
25
|
+
actions: [
|
|
26
|
+
'com.heytap.mcs.action.RECEIVE_MCS_MESSAGE',
|
|
27
|
+
'com.heytap.msp.push.RECEIVE_MCS_MESSAGE',
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
const withDooPushOppoManifest = (config, validated) => {
|
|
32
|
+
// service 类来自 oppo-push 依赖,仅在启用 OPPO vendor 时注入。
|
|
33
|
+
if (!validated.android.vendors.oppo) {
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
36
|
+
return (0, config_plugins_1.withAndroidManifest)(config, (cfg) => {
|
|
37
|
+
var _a;
|
|
38
|
+
config_plugins_1.AndroidConfig.Permissions.ensurePermissions(cfg.modResults, MCS_PERMISSIONS);
|
|
39
|
+
const application = config_plugins_1.AndroidConfig.Manifest.getMainApplication(cfg.modResults);
|
|
40
|
+
if (!application)
|
|
41
|
+
return cfg;
|
|
42
|
+
application.service = (_a = application.service) !== null && _a !== void 0 ? _a : [];
|
|
43
|
+
for (const svc of MCS_SERVICES) {
|
|
44
|
+
const exists = application.service.some((s) => { var _a; return ((_a = s.$) === null || _a === void 0 ? void 0 : _a['android:name']) === svc.name; });
|
|
45
|
+
if (exists)
|
|
46
|
+
continue;
|
|
47
|
+
application.service.push({
|
|
48
|
+
$: {
|
|
49
|
+
'android:name': svc.name,
|
|
50
|
+
'android:permission': svc.permission,
|
|
51
|
+
'android:exported': 'true',
|
|
52
|
+
},
|
|
53
|
+
'intent-filter': [
|
|
54
|
+
{ action: svc.actions.map((a) => ({ $: { 'android:name': a } })) },
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return cfg;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
exports.withDooPushOppoManifest = withDooPushOppoManifest;
|