mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-01 13:53:11 +08:00
Add client info and uuid
This commit is contained in:
19
lib/index.js
19
lib/index.js
@@ -5,6 +5,11 @@ import {
|
||||
} from './endpoint';
|
||||
import { NativeAppEventEmitter, NativeModules, Platform } from 'react-native';
|
||||
export { setCustomEndpoints };
|
||||
const {
|
||||
version: v,
|
||||
} = require('react-native/Libraries/Core/ReactNativeVersion');
|
||||
const RNVersion = `${v.major}.${v.minor}.${v.patch}`;
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
let Pushy = NativeModules.Pushy;
|
||||
|
||||
@@ -19,6 +24,7 @@ export const isFirstTime = Pushy.isFirstTime;
|
||||
export const isRolledBack = Pushy.isRolledBack;
|
||||
export const buildTime = Pushy.buildTime;
|
||||
let blockUpdate = Pushy.blockUpdate;
|
||||
let uuid = Pushy.uuid;
|
||||
|
||||
if (Platform.OS === 'android' && !Pushy.isUsingBundleUrl) {
|
||||
throw new Error(
|
||||
@@ -26,6 +32,13 @@ if (Platform.OS === 'android' && !Pushy.isUsingBundleUrl) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!uuid) {
|
||||
uuid = uuidv4();
|
||||
Pushy.setUuid(uuid);
|
||||
}
|
||||
|
||||
console.log('Pushy uuid: ' + uuid);
|
||||
|
||||
/*
|
||||
Return json:
|
||||
Package expired:
|
||||
@@ -77,6 +90,12 @@ export async function checkUpdate(APPKEY, isRetry) {
|
||||
packageVersion,
|
||||
hash: currentVersion,
|
||||
buildTime,
|
||||
cInfo: {
|
||||
pushy: require('../package.json').version,
|
||||
rn: RNVersion,
|
||||
os: Platform.OS + ' ' + Platform.Version,
|
||||
uuid,
|
||||
},
|
||||
}),
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user