[android] initial link - save the initial link and return it instead of returning null on repeated calls
This commit is contained in:
parent
79ab970e0a
commit
559b4f1329
|
@ -29,6 +29,7 @@ import io.invertase.firebase.Utils;
|
||||||
|
|
||||||
public class RNFirebaseLinks extends ReactContextBaseJavaModule implements ActivityEventListener {
|
public class RNFirebaseLinks extends ReactContextBaseJavaModule implements ActivityEventListener {
|
||||||
private final static String TAG = RNFirebaseLinks.class.getCanonicalName();
|
private final static String TAG = RNFirebaseLinks.class.getCanonicalName();
|
||||||
|
private String initialLink = null;
|
||||||
|
|
||||||
public RNFirebaseLinks(ReactApplicationContext reactContext) {
|
public RNFirebaseLinks(ReactApplicationContext reactContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
|
@ -52,13 +53,12 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
||||||
// Get deep link from result (may be null if no link is found or run on the same intent again)
|
// Get deep link from result (may be null if no link is found or run on the same intent again)
|
||||||
if (pendingDynamicLinkData != null) {
|
if (pendingDynamicLinkData != null) {
|
||||||
Uri deepLinkUri = pendingDynamicLinkData.getLink();
|
Uri deepLinkUri = pendingDynamicLinkData.getLink();
|
||||||
String deepLink = deepLinkUri.toString();
|
initialLink = deepLinkUri.toString();
|
||||||
Log.d(TAG, "getInitialLink: received a dynamic link: " + deepLink);
|
Log.d(TAG, "getInitialLink: received a new dynamic link from pendingDynamicLinkData");
|
||||||
promise.resolve(deepLink);
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "getInitialLink: no pendingDynamicLinkData." );
|
|
||||||
promise.resolve(null);
|
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "getInitialLink: initial link is: " + initialLink );
|
||||||
|
promise.resolve(initialLink);
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addOnFailureListener(activity, new OnFailureListener() {
|
.addOnFailureListener(activity, new OnFailureListener() {
|
||||||
|
@ -70,7 +70,7 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "getInitialLink: activity is null" );
|
Log.d(TAG, "getInitialLink: activity is null" );
|
||||||
promise.resolve(null);
|
promise.resolve(initialLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class RNFirebaseLinks extends ReactContextBaseJavaModule implements Activ
|
||||||
if (pendingDynamicLinkData != null) {
|
if (pendingDynamicLinkData != null) {
|
||||||
Uri deepLinkUri = pendingDynamicLinkData.getLink();
|
Uri deepLinkUri = pendingDynamicLinkData.getLink();
|
||||||
String deepLink = deepLinkUri.toString();
|
String deepLink = deepLinkUri.toString();
|
||||||
Log.d(TAG, "handleLink: sending a dynamic link: " + deepLink);
|
Log.d(TAG, "handleLink: sending link: " + deepLink);
|
||||||
Utils.sendEvent(getReactApplicationContext(), "dynamic_link_received", deepLink);
|
Utils.sendEvent(getReactApplicationContext(), "dynamic_link_received", deepLink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue