feat(update): 添加应用更新检查功能支持用户ID参数
- 在UpdateApi接口中新增可选的userId查询参数 - 新增UpdateSDK对象用于统一管理应用更新逻辑 - 实现应用版本检查、下载安装和APK文件处理功能 - 添加下载URL规范化处理逻辑 - 在Flutter SDK中新增update模块实现跨平台更新功能 - 在iOS SDK中新增UpdateSDK类提供应用更新检查接口 - 支持Android和iOS平台的应用商店跳转功能 - 添加React Native SDK的更新检查和插件注册功能 - 实现RN Bundle的检查、下载和缓存机制
这个提交包含在:
父节点
9adc3e3084
当前提交
09d42fa94f
@ -1,6 +1,6 @@
|
|||||||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||||
import { Linking, Platform } from 'react-native'
|
import { Linking, Platform } from 'react-native'
|
||||||
import { apiRequest, getConfig } from '@xuqm/rn-common'
|
import { apiRequest, getConfig, getUserId } from '@xuqm/rn-common'
|
||||||
import { getAppVersionCode, getAppVersionName, _devSetAppVersion } from './NativeVersion'
|
import { getAppVersionCode, getAppVersionName, _devSetAppVersion } from './NativeVersion'
|
||||||
|
|
||||||
export interface PluginMeta {
|
export interface PluginMeta {
|
||||||
@ -86,13 +86,18 @@ export const UpdateSDK = {
|
|||||||
async checkAppUpdate(): Promise<AppUpdateInfo> {
|
async checkAppUpdate(): Promise<AppUpdateInfo> {
|
||||||
const config = getConfig()
|
const config = getConfig()
|
||||||
const currentVersionCode = getAppVersionCode()
|
const currentVersionCode = getAppVersionCode()
|
||||||
|
const userId = getUserId()?.trim()
|
||||||
|
const params: Record<string, string> = {
|
||||||
|
appKey: config.appKey,
|
||||||
|
platform: Platform.OS === 'android' ? 'ANDROID' : 'IOS',
|
||||||
|
currentVersionCode: String(currentVersionCode),
|
||||||
|
}
|
||||||
|
if (userId) {
|
||||||
|
params.userId = userId
|
||||||
|
}
|
||||||
const result = await apiRequest<AppUpdateInfo>('/api/v1/updates/app/check', {
|
const result = await apiRequest<AppUpdateInfo>('/api/v1/updates/app/check', {
|
||||||
skipAuth: true,
|
skipAuth: true,
|
||||||
params: {
|
params,
|
||||||
appKey: config.appKey,
|
|
||||||
platform: Platform.OS === 'android' ? 'ANDROID' : 'IOS',
|
|
||||||
currentVersionCode: String(currentVersionCode),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
return { ...result, downloadUrl: normalizeDownloadUrl(result.downloadUrl) }
|
return { ...result, downloadUrl: normalizeDownloadUrl(result.downloadUrl) }
|
||||||
},
|
},
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户