add apns supports.

This commit is contained in:
aria committed 2026-04-23 15:38:20 +09:00
1 parent 855d24bc64
commit 21c392db8f
6 files changed
+442 -31

No files matched your search

+23 -2
View File
@@ -136,7 +136,23 @@ BluememeUtils.getInitialNotification(success, error);
BluememeUtils.stopNotificationListener(success, error);
```
`getPushPermissionStatus` 只读取当前系统通知状态,不弹授权框。可用于填充后端 `NotificationsEnabled`。
`getPushPermissionStatus` 只读取当前系统通知状态,不弹授权框。可用于填充后端 `NotificationsEnabled`。iOS 返回 `authorizationStatus: "notDetermined"` 时,说明还没有触发系统通知授权弹窗,需要先调用 `requestPushPermission`,用户授权后再调用 `getFirebaseToken`。
iOS 获取 FCM token 的推荐顺序:
```js
BluememeUtils.requestPushPermission(function (permission) {
if (permission.enabled !== true) {
return;
}
BluememeUtils.getFirebaseToken(function (result) {
console.log(result.token);
}, error);
}, error);
```
iOS 上 FCM token 依赖 APNs device token。插件会在 `getFirebaseToken` 内等待 Cordova 收到 APNs token 后再向 Firebase 请求 FCM token;如果 APNs token 超时或注册失败,会返回 `APNS_TOKEN_NOT_AVAILABLE` 或 `APNS_TOKEN_FAILED`。
返回示例:
@@ -224,7 +240,10 @@ iOS WiFi:
Firebase:
- Android 13+ 需要通知权限,调用 `requestPushPermission`。
- iOS 需要 Push Notifications capability、Background Modes 中的 Remote notifications,以及 APNs key/certificate 已配置到 Firebase。
- iOS 需要 Apple Developer App ID 开启 Push Notifications,并使用重新生成的 provisioning profile 构建。
- 插件会向 Cordova iOS entitlements 写入 `aps-environment`:Debug 为 `development`,Release 为 `production`。仍建议在构建后的 IPA 中检查签名 entitlements 是否包含该 key。
- Firebase Console 需要在 Project Settings > Cloud Messaging > Apple app configuration 中上传 APNs Auth Key `.p8` 或 APNs certificate。推荐使用 APNs Auth Key。
- Background Modes 中的 Remote notifications 只影响后台静默推送/后台唤醒,不是获取 APNs token 和 FCM token 的前置条件。
- 如果项目中还有其他推送插件,也可能同时修改 `UNUserNotificationCenterDelegate` 或 Firebase service,需要在真机上确认通知打开事件。
Biometric:
@@ -249,6 +268,8 @@ Biometric:
- `INVALID_WIFI_OPTIONS`
- `WIFI_CONNECT_FAILED`
- `FIREBASE_NOT_CONFIGURED`
- `APNS_TOKEN_NOT_AVAILABLE`
- `APNS_TOKEN_FAILED`
- `FCM_TOKEN_FAILED`
- `BIOMETRIC_UNAVAILABLE`
- `AUTHENTICATION_ERROR`