XuqmGroup-RNSDK/packages/push/src/NativePush.ts
XuqmGroup a58f920a3f feat(android-sdk): 添加完整的IM客户端SDK实现
- 实现了Android SDK的完整IM功能接口,包括消息、群组、好友、会话等核心功能
- 添加了消息收发、历史记录、撤回编辑等完整的消息操作能力
- 实现了群组管理功能,包括创建、成员管理、权限设置等操作
- 添加了好友关系链管理,支持添加、删除、分组等操作
- 实现了会话管理功能,包括置顶、免打扰、已读状态等
- 添加了黑名单、资料管理、搜索等辅助功能
- 补齐了批量操作接口,提升客户端操作效率
- 实现了WebSocket连接管理和事件监听机制
- 添加了离线消息同步和状态管理功能
2026-05-02 22:57:55 +08:00

34 行
1013 B
TypeScript

import { NativeModules, NativeEventEmitter, Platform } from 'react-native'
interface XuqmPushModuleInterface {
detectVendor: () => Promise<string>
registerPush: () => Promise<boolean>
}
const _native = NativeModules.XuqmPushModule as XuqmPushModuleInterface | undefined
const _eventEmitter = _native ? new NativeEventEmitter(_native as any) : null
export function isNativePushAvailable(): boolean {
return !!_native
}
export async function detectVendorNative(): Promise<string> {
if (!_native?.detectVendor) return Platform.OS === 'ios' ? 'APNS' : 'FCM'
return _native.detectVendor()
}
export async function registerPushNative(): Promise<void> {
if (!_native?.registerPush) return
await _native.registerPush()
}
export function addPushTokenListener(
callback: (event: { token: string; vendor: string }) => void,
): () => void {
if (!_eventEmitter) {
return () => {}
}
const subscription = _eventEmitter.addListener('XuqmPushToken', callback)
return () => subscription.remove()
}