File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed
android/src/main/java/io/branch/rnbranch Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -445,6 +445,21 @@ public void setIdentity(String identity) {
445445 branch .setIdentity (identity );
446446 }
447447
448+ @ ReactMethod
449+ public void setIdentityAsync (String identity , Promise promise ) {
450+ Branch branch = Branch .getInstance ();
451+ branch .setIdentity (identity , new BranchReferralInitListener () {
452+ @ Override
453+ public void onInitFinished (JSONObject referringParams , BranchError error ) {
454+ if (error != null ) {
455+ promise .reject ("RNBranch::Error::setIdentityAsync failed" , error .getMessage ());
456+ } else {
457+ promise .resolve (convertJsonToMap (referringParams ));
458+ }
459+ }
460+ });
461+ }
462+
448463 @ ReactMethod
449464 public void setRequestMetadataKey (String key , String value ) {
450465 // setRequestMetadata does not do what it appears to do. Call directly to the native code.
Original file line number Diff line number Diff line change @@ -407,6 +407,21 @@ - (BranchUniversalObject *)findUniversalObjectWithIdent:(NSString *)ident reject
407407 [self .class.branch setIdentity: identity];
408408}
409409
410+ #pragma mark setIdentityAsync
411+ RCT_EXPORT_METHOD (
412+ setIdentityAsync:(NSString *)identity
413+ resolver:(RCTPromiseResolveBlock)resolve
414+ rejecter:(__unused RCTPromiseRejectBlock)reject
415+ ) {
416+ [self .class.branch setIdentity: identity withCallback: ^(NSDictionary *params, NSError *error) {
417+ if (!error) {
418+ resolve (params);
419+ } else {
420+ reject (@" RNBranch::Error::setIdentityAsync failed" , error.localizedDescription , error);
421+ }
422+ }];
423+ }
424+
410425#pragma mark setRequestMetadataKey
411426RCT_EXPORT_METHOD (
412427 setRequestMetadataKey:(NSString *)key
Original file line number Diff line number Diff line change @@ -322,6 +322,7 @@ interface Branch {
322322 getFirstReferringParams : ( ) => Promise < BranchParams > ;
323323 lastAttributedTouchData : ( attributionWindow ?: number ) => Promise < BranchParams > ;
324324 setIdentity : ( identity : string ) => void ;
325+ setIdentityAsync : ( identity : string ) => Promise < BranchParams > ;
325326 setRequestMetadata : ( key : string , value : string ) => void ;
326327 addFacebookPartnerParameter : ( name : string , value : string ) => void ;
327328 clearPartnerParameters : ( ) => void ;
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ class Branch {
6262 getFirstReferringParams = RNBranch . getFirstReferringParams
6363 lastAttributedTouchData = ( attributionWindow = { } ) => RNBranch . lastAttributedTouchData ( attributionWindow )
6464 setIdentity = ( identity ) => RNBranch . setIdentity ( identity )
65+ setIdentityAsync = ( identity ) => RNBranch . setIdentityAsync ( identity )
6566 setRequestMetadata = ( key , value ) => {
6667 console . info ( '[Branch] setRequestMetadata has limitations when called from JS. Some network calls are made prior to the JS layer being available, those calls will not have the metadata.' )
6768 return RNBranch . setRequestMetadataKey ( key , value )
You can’t perform that action at this time.
0 commit comments