File tree Expand file tree Collapse file tree
android/app/src/main/java/com/appzung/codepush/react Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -731,6 +731,20 @@ public void clearUpdates() {
731731 mCodePush .clearUpdates ();
732732 }
733733
734+ @ ReactMethod
735+ public void resetClientUniqueId (Promise promise ) {
736+ try {
737+ String newClientUniqueId = UUID .randomUUID ().toString ();
738+ SharedPreferences preferences = mCodePush .getContext ().getSharedPreferences (CodePushConstants .CODE_PUSH_PREFERENCES , 0 );
739+ preferences .edit ().putString (CodePushConstants .CLIENT_UNIQUE_ID_KEY , newClientUniqueId ).apply ();
740+ mClientUniqueId = newClientUniqueId ;
741+ promise .resolve (mClientUniqueId );
742+ } catch (Exception e ) {
743+ CodePushUtils .log (e );
744+ promise .reject (e );
745+ }
746+ }
747+
734748 @ ReactMethod
735749 public void addListener (String eventName ) {
736750 // Set up any upstream listeners or background tasks as necessary
Original file line number Diff line number Diff line change 101101@property (readonly ) NSString *buildVersion;
102102@property (readonly ) NSDictionary *configuration;
103103@property (copy ) NSString *releaseChannelPublicId;
104+ @property (readonly ) NSString *clientUniqueId;
104105@property (copy ) NSString *serverURL;
105106@property (copy ) NSString *publicKey;
106107
Original file line number Diff line number Diff line change @@ -1042,6 +1042,13 @@ - (void)restartAppInternal:(BOOL)onlyIfUpdateIsPending
10421042 [CodePush clearUpdates ];
10431043}
10441044
1045+ RCT_EXPORT_METHOD (resetClientUniqueId:(RCTPromiseResolveBlock)resolve
1046+ rejecter:(RCTPromiseRejectBlock)reject)
1047+ {
1048+ CPLog (@" On iOS, resetting client device ID does nothing as it is the iOS IDFV." );
1049+ resolve ([[CodePushConfig current ] clientUniqueId ]);
1050+ }
1051+
10451052#pragma mark - JavaScript-exported module methods (Private)
10461053
10471054/*
Original file line number Diff line number Diff line change 1+ import { getConfiguration } from './internals/getConfiguration' ;
2+
3+ /**
4+ * Gets the client's unique ID set by the module. You may also see resetClientUniqueId.
5+ */
6+ export const getClientUniqueId = async ( ) => {
7+ const nativeConfig = await getConfiguration ( ) ;
8+ return nativeConfig . clientUniqueId ;
9+ } ;
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ export * from './getUpdateMetadata';
88export * from './notifyAppReady' ;
99export * from './restartApp' ;
1010export * from './sync' ;
11+ export * from './getClientUniqueId' ;
12+ export * from './resetClientUniqueId' ;
1113
1214export * from './types' ;
1315
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export interface Spec extends TurboModule {
2020 } ;
2121
2222 getConfiguration ( ) : Promise < Configuration > ;
23+ resetClientUniqueId ( ) : Promise < string > ;
2324
2425 getUpdateMetadata ( updateState : UpdateState ) : Promise < OmitFunctions < LocalPackage > > ;
2526 installUpdate (
Original file line number Diff line number Diff line change @@ -10,3 +10,7 @@ export async function getConfiguration() {
1010
1111 return config ;
1212}
13+
14+ export async function reloadCachedConfiguration ( ) {
15+ config = await NativeRNAppZungCodePushModule . getConfiguration ( ) ;
16+ }
Original file line number Diff line number Diff line change 1+ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule' ;
2+ import { reloadCachedConfiguration } from './internals/getConfiguration' ;
3+
4+ /**
5+ * Resets the client's unique ID. You may use this in some GDPR compliance scenarios. Note that this will create a new MAU if a new request is sent later.
6+ */
7+ export const resetClientUniqueId = async ( ) => {
8+ const newId = await NativeRNAppZungCodePushModule . resetClientUniqueId ( ) ;
9+ await reloadCachedConfiguration ( ) ;
10+ return newId ;
11+ } ;
You can’t perform that action at this time.
0 commit comments