Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: appUrlOpen listener not called on Android if app launched with ACTION_MAIN #127

Open
jh-gh opened this issue Dec 5, 2020 · 1 comment

Comments

@jh-gh
Copy link

jh-gh commented Dec 5, 2020

Bug Report

Plugin(s)

Core App plugin on Android, Capacitor 2.4.3

Capacitor Version

Latest Dependencies:
  @capacitor/cli: 2.4.4
  @capacitor/core: 2.4.4
  @capacitor/android: 2.4.4
  @capacitor/electron: 2.4.4
  @capacitor/ios: 2.4.4

Installed Dependencies:

  @capacitor/ios not installed
  @capacitor/cli 2.4.3
  @capacitor/core 2.4.3
  @capacitor/android 2.4.3
  @capacitor/electron not installed

Platform(s)

Android

Current Behavior

When the app is launched with a uri and ACTION_MAIN, the appUrlOpen listener is NOT called.
If the app is launched the same way but with ACTION_VIEW then the appUrlOpen listener IS called.

Expected Behavior

The appUrlOpen listener should be called as long as there is some data uri ... even if the action is ACTION_MAIN.
The code currently checks both the uri and action and only continues if the action is set to ACTION_VIEW.

I'm not sure exactly what should be checked here ... but ideally, this listener should also be called if the app is launched with ACTION_MAIN.

With the Cordova com.lampa.startapp plugin, by default, when you launch another application, the intent will have ACTION_MAIN. When using the Cordova Custom-URL-scheme plugin in the launched app, this would call the app's handleOpenURL method. I would like to convert the launched app to Capacitor and use the Capacitor App plugin instead of the Cordova Custom-URL-scheme plugin. However, this doesn't work ... because the Capacitor plugin does not call the appUrlOpen listener when the app is launched with ACTION_MAIN. Unfortunately, it is not practical to change all of the apps that launch this app to always launch with ACTION_MAIN.

Code Reproduction

Other Technical Details

Additional Context

A simple fix for this would be to remove the check for ACTION_VIEW in the handleOnNewIntent method in App.java (or at least add a check for ACTION_MAIN as well as ACTION_VIEW

A workaround for this issue is to use the plugin cordova-plugin-customurlscheme in your capacitor app. See also: EddyVerbruggen/Custom-URL-scheme#332

@dchappelle
Copy link

I'm experiencing this problem using Capacitor v2 latest, any planned fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants