ionic-team / ionic-plugin-deeplinks

Handle deeplinks into your Ionic/Cordova apps from Universal Links, App Links, and Custom URL schemes. For those using Ionic 2, there are some nice goodies that make life easier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App relaunches when deeplink is clicked[Android]

RobinGiel opened this issue · comments

When clicking on a deeplink or redirecting the deeplink to my app to app relaunches.
I'm guessing this has to with Main.activity being called. Or getting the intent without any flags.

public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Log.d(TAG, "IonicDeepLinkPlugin: firing up...");
handleIntent(cordova.getActivity().getIntent());
}
@Override
public void onNewIntent(Intent intent) {
handleIntent(intent);
}
public void handleIntent(Intent intent) {
final String intentString = intent.getDataString();
// read intent
String action = intent.getAction();
Uri url = intent.getData();
JSONObject bundleData = this._bundleToJson(intent.getExtras());
Log.d(TAG, "Got a new intent: " + intentString + " " + intent.getScheme() + " " + action + " " + url);
// if app was not launched by the url - ignore
if (!Intent.ACTION_VIEW.equals(action) || url == null) {
return;
}

@RobinGiel I don't know if this is still an issue for you, but you may want to double check the Android setup documentation:
"To prevent Android from creating multiple app instances when opening deeplinks, you can add the following preference in Cordova config.xml file: <preference name="AndroidLaunchMode" value="singleTask" />"

Thanks for the reply @JacoRoos