File tree Expand file tree Collapse file tree 4 files changed +47
-3
lines changed
android/src/main/java/io/branch/rnbranch Expand file tree Collapse file tree 4 files changed +47
-3
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 @@ -276,13 +276,25 @@ interface BranchLinkControlParams {
276276 $samsung_url ?: string ;
277277}
278278
279+ interface BranchShareSuccess {
280+ completed : true ;
281+ error : null ;
282+ channel : string ;
283+ }
284+
285+ interface BranchShareFailure {
286+ completed : false ;
287+ error : null | string ;
288+ channel : null ;
289+ }
290+
279291interface BranchUniversalObject {
280292 ident : string ;
281293 showShareSheet : (
282294 shareOptions ?: BranchShareSheetOptions ,
283295 linkProperties ?: BranchLinkProperties ,
284296 controlParams ?: BranchLinkControlParams
285- ) => void ;
297+ ) => Promise < BranchShareSuccess | BranchShareFailure > ;
286298 generateShortUrl : (
287299 linkProperties : BranchLinkProperties ,
288300 controlParams : BranchLinkControlParams
@@ -310,9 +322,10 @@ interface Branch {
310322 getFirstReferringParams : ( ) => Promise < BranchParams > ;
311323 lastAttributedTouchData : ( attributionWindow ?: number ) => Promise < BranchParams > ;
312324 setIdentity : ( identity : string ) => void ;
325+ setIdentityAsync : ( identity : string ) => Promise < BranchParams > ;
313326 setRequestMetadata : ( key : string , value : string ) => void ;
314327 addFacebookPartnerParameter : ( name : string , value : string ) => void ;
315- clearPartnerParameter : ( ) => void ;
328+ clearPartnerParameters : ( ) => void ;
316329 logout : ( ) => void ;
317330 openURL : ( url : string , options ?: { newActivity ?: boolean } ) => void ;
318331 createBranchUniversalObject : (
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 )
@@ -70,7 +71,7 @@ class Branch {
7071 console . info ( '[Branch] addFacebookPartnerParameter has limitations when called from JS. Some network calls are made prior to the JS layer being available, those calls will not have the partner parameters.' )
7172 return RNBranch . addFacebookPartnerParameter ( name , value )
7273 }
73- clearPartnerParameter = RNBranch . clearPartnerParameter
74+ clearPartnerParameters = RNBranch . clearPartnerParameters
7475 logout = RNBranch . logout
7576 userCompletedAction = ( event , state = { } ) => RNBranch . userCompletedAction ( event , state )
7677 getShortUrl = RNBranch . getShortUrl
You can’t perform that action at this time.
0 commit comments