File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed
android/src/main/java/io/branch/rnbranch Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -504,21 +504,27 @@ These session parameters will be available at any point later on with this comma
504504#### Method
505505
506506``` js
507- branch .getLatestReferringParams ()
507+ branch .getLatestReferringParams (synchronous = false )
508508```
509509
510510##### Return
511511
512512A promise. On resolution, the promise returns an object containing the parameters
513513from the latest link open or install. See [ Params object] ( #params-object ) for
514- details on the contents.
514+ details on the contents. Depending on the value of the argument, the promise may
515+ return right away, possibly with values from the user defaults (iOS) or user
516+ preferences (Android) or wait until an open response is received.
515517
516518#### Example
517519
518520``` js
519521import branch from ' react-native-branch'
520522
523+ // don't wait for open response
521524const latestParams = await branch .getLatestReferringParams ()
525+
526+ // wait for open response
527+ const latestParams = await branch .getLatestReferringParams (true )
522528```
523529
524530___
Original file line number Diff line number Diff line change @@ -349,9 +349,12 @@ public void redeemInitSessionResult(Promise promise) {
349349 }
350350
351351 @ ReactMethod
352- public void getLatestReferringParams (Promise promise ) {
352+ public void getLatestReferringParams (boolean synchronous , Promise promise ) {
353353 Branch branch = Branch .getInstance ();
354- promise .resolve (convertJsonToMap (branch .getLatestReferringParamsSync ()));
354+ if (synchronous )
355+ promise .resolve (convertJsonToMap (branch .getLatestReferringParamsSync ()));
356+ else
357+ promise .resolve (convertJsonToMap (branch .getLatestReferringParams ()));
355358 }
356359
357360 @ ReactMethod
Original file line number Diff line number Diff line change @@ -349,10 +349,14 @@ - (BranchUniversalObject *)findUniversalObjectWithIdent:(NSString *)ident reject
349349
350350#pragma mark getLatestReferringParams
351351RCT_EXPORT_METHOD (
352- getLatestReferringParams:(RCTPromiseResolveBlock)resolve
352+ getLatestReferringParams:(NSNumber * __nonnull)synchronous
353+ resolver:(RCTPromiseResolveBlock)resolve
353354 rejecter:(__unused RCTPromiseRejectBlock)reject
354355 ) {
355- resolve ([self .class.branch getLatestReferringParamsSynchronous ]);
356+ if (synchronous.boolValue )
357+ resolve ([self .class.branch getLatestReferringParamsSynchronous ]);
358+ else
359+ resolve ([self .class.branch getLatestReferringParams ]);
356360}
357361
358362#pragma mark getFirstReferringParams
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ class Branch {
107107
108108 /*** RNBranch singleton methods ***/
109109 setDebug = ( ) => { throw 'setDebug() is not supported in the RN SDK. For other solutions, please see https://rnbranch.app.link/setDebug' }
110- getLatestReferringParams = RNBranch . getLatestReferringParams
110+ getLatestReferringParams = ( synchronous = false ) => RNBranch . getLatestReferringParams ( synchronous )
111111 getFirstReferringParams = RNBranch . getFirstReferringParams
112112 setIdentity = ( identity ) => RNBranch . setIdentity ( identity )
113113 logout = RNBranch . logout
You can’t perform that action at this time.
0 commit comments