import { Platform } from 'react-native' import { apiRequest, getConfig } from '@xuqm/rn-common' export type PushVendor = 'HUAWEI' | 'XIAOMI' | 'OPPO' | 'VIVO' | 'HONOR' | 'APNS' | 'FCM' export const PushSDK = { /** * Register a push device token for the given user. * Call this after obtaining a vendor push token (e.g. via Firebase or APNS callbacks). * * @param userId - The logged-in user's ID * @param vendor - Push vendor (e.g. HUAWEI, XIAOMI, APNS) * @param token - The device push token from the vendor */ async registerToken(userId: string, vendor: PushVendor, token: string): Promise { const config = getConfig() await apiRequest('/api/push/register', { method: 'POST', params: { appId: config.appId, userId, vendor, token, platform: Platform.OS === 'android' ? 'ANDROID' : 'IOS', }, }) }, async unregisterToken(userId: string): Promise { const config = getConfig() await apiRequest('/api/push/unregister', { method: 'DELETE', params: { appId: config.appId, userId }, }) }, }