1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-31 21:33:12 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Add client info and uuid

This commit is contained in:
sunnylqm
2020-08-31 11:47:08 +08:00
parent 9e6c7ea769
commit c6f9bb20a1
4 changed files with 38 additions and 2592 deletions

View File

@@ -22,12 +22,14 @@
// //
static NSString *const keyPushyInfo = @"REACTNATIVECN_PUSHY_INFO_KEY"; static NSString *const keyPushyInfo = @"REACTNATIVECN_PUSHY_INFO_KEY";
static NSString *const keyPushyInfo = @"REACTNATIVECN_PUSHY_INFO_KEY";
static NSString *const paramPackageVersion = @"packageVersion"; static NSString *const paramPackageVersion = @"packageVersion";
static NSString *const paramLastVersion = @"lastVersion"; static NSString *const paramLastVersion = @"lastVersion";
static NSString *const paramCurrentVersion = @"currentVersion"; static NSString *const paramCurrentVersion = @"currentVersion";
static NSString *const paramIsFirstTime = @"isFirstTime"; static NSString *const paramIsFirstTime = @"isFirstTime";
static NSString *const paramIsFirstLoadOk = @"isFirstLoadOK"; static NSString *const paramIsFirstLoadOk = @"isFirstLoadOK";
static NSString *const keyBlockUpdate = @"blockUpdate" static NSString *const keyBlockUpdate = @"REACTNATIVECN_PUSHY_BLOCKUPDATE";
static NSString *const keyUuid = @"REACTNATIVECN_PUSHY_UUID";
static NSString *const keyFirstLoadMarked = @"REACTNATIVECN_PUSHY_FIRSTLOADMARKED_KEY"; static NSString *const keyFirstLoadMarked = @"REACTNATIVECN_PUSHY_FIRSTLOADMARKED_KEY";
static NSString *const keyRolledBackMarked = @"REACTNATIVECN_PUSHY_ROLLEDBACKMARKED_KEY"; static NSString *const keyRolledBackMarked = @"REACTNATIVECN_PUSHY_ROLLEDBACKMARKED_KEY";
static NSString *const KeyPackageUpdatedMarked = @"REACTNATIVECN_PUSHY_ISPACKAGEUPDATEDMARKED_KEY"; static NSString *const KeyPackageUpdatedMarked = @"REACTNATIVECN_PUSHY_ISPACKAGEUPDATEDMARKED_KEY";
@@ -157,6 +159,7 @@ RCT_EXPORT_MODULE(RCTPushy);
ret[@"isRolledBack"] = [defaults objectForKey:keyRolledBackMarked]; ret[@"isRolledBack"] = [defaults objectForKey:keyRolledBackMarked];
ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadMarked]; ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadMarked];
ret[@"blockUpdate"] = [defaults objectForKey:keyBlockUpdate]; ret[@"blockUpdate"] = [defaults objectForKey:keyBlockUpdate];
ret[@"uuid"] = [defaults objectForKey:keyUuid];
NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo]; NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
ret[@"currentVersion"] = [pushyInfo objectForKey:paramCurrentVersion]; ret[@"currentVersion"] = [pushyInfo objectForKey:paramCurrentVersion];
@@ -200,6 +203,13 @@ RCT_EXPORT_METHOD(setBlockUpdate:(NSDictionary *)options)
[defaults synchronize]; [defaults synchronize];
} }
RCT_EXPORT_METHOD(setUuid:(NSString *)uuid)
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:uuid forKey:keyUuid];
[defaults synchronize];
}
RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary *)options RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary *)options
resolver:(RCTPromiseResolveBlock)resolve resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject) rejecter:(RCTPromiseRejectBlock)reject)

View File

@@ -5,6 +5,11 @@ import {
} from './endpoint'; } from './endpoint';
import { NativeAppEventEmitter, NativeModules, Platform } from 'react-native'; import { NativeAppEventEmitter, NativeModules, Platform } from 'react-native';
export { setCustomEndpoints }; 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; let Pushy = NativeModules.Pushy;
@@ -19,6 +24,7 @@ export const isFirstTime = Pushy.isFirstTime;
export const isRolledBack = Pushy.isRolledBack; export const isRolledBack = Pushy.isRolledBack;
export const buildTime = Pushy.buildTime; export const buildTime = Pushy.buildTime;
let blockUpdate = Pushy.blockUpdate; let blockUpdate = Pushy.blockUpdate;
let uuid = Pushy.uuid;
if (Platform.OS === 'android' && !Pushy.isUsingBundleUrl) { if (Platform.OS === 'android' && !Pushy.isUsingBundleUrl) {
throw new Error( 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: Return json:
Package expired: Package expired:
@@ -77,6 +90,12 @@ export async function checkUpdate(APPKEY, isRetry) {
packageVersion, packageVersion,
hash: currentVersion, hash: currentVersion,
buildTime, buildTime,
cInfo: {
pushy: require('../package.json').version,
rn: RNVersion,
os: Platform.OS + ' ' + Platform.Version,
uuid,
},
}), }),
}); });
} catch (e) { } catch (e) {

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "5.7.0", "version": "5.7.1",
"description": "react-native hot update", "description": "react-native hot update",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
@@ -26,5 +26,7 @@
"react-native": ">=0.27.0" "react-native": ">=0.27.0"
}, },
"homepage": "https://github.com/reactnativecn/react-native-pushy#readme", "homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
"dependencies": {} "dependencies": {
"uuid": "^8.3.0"
}
} }

2593
yarn.lock

File diff suppressed because it is too large Load Diff