feat(push): integrate Honor and Xiaomi push plugins with related updates

This commit is contained in:
lafay
2026-06-18 00:03:37 +08:00
parent b2979311bb
commit 96e8de18bf
20 changed files with 1088 additions and 265 deletions

View File

@@ -2,7 +2,6 @@ import { useEffect, useRef } from 'react';
import { Platform } from 'react-native';
import { jpushService } from '../services/notification/jpushService';
import { isAutoStartAllowed } from '../services/consent/autoStartConsent';
export function useRegisterPushDevice(isAuthenticated: boolean, userID?: string) {
const deviceRegistered = useRef(false);
@@ -10,12 +9,12 @@ export function useRegisterPushDevice(isAuthenticated: boolean, userID?: string)
useEffect(() => {
if (Platform.OS === 'web' || !isAuthenticated || !userID) return;
// 仅在用户同意自启动后才初始化 JPush
if (!isAutoStartAllowed()) {
console.log('[useRegisterPushDevice] 用户未同意自启动,跳过 JPush 初始化');
return;
}
// JPush 初始化只取决于登录态——这是基础推送通道(获取 RegistrationID、
// 向服务器注册设备 token与"是否允许后台自启动/保活"无关。
// 后台保活由 backgroundService 控制;退后台是否保持 JPush 长连接由
// jpushService._setBackgroundKeepLongConn() 根据 autoStart 同意状态自行处理。
// 若在此处用 consent 拦截 init未同意用户将永远拿不到 RegistrationID
// 即便在前台/已授予通知权限也无法收到推送。
if (!deviceRegistered.current) {
deviceRegistered.current = true;