question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

bug: android appUrlOpen never fires

See original GitHub issue

Bug Report

Capacitor Version

๐Ÿ’Š   Capacitor Doctor  ๐Ÿ’Š 

Latest Dependencies:

  @capacitor/cli: 2.2.0

  @capacitor/core: 2.2.0

  @capacitor/android: 2.2.0

  @capacitor/electron: 2.2.0

  @capacitor/ios: 2.2.0

Installed Dependencies:

  @capacitor/electron not installed


  @capacitor/cli 2.2.0

  @capacitor/core 2.2.0

  @capacitor/android 2.2.0

  @capacitor/ios 2.2.0

[success] Android looking great! ๐Ÿ‘Œ
  Found 16 Capacitor plugins for ios:
    call-number (1.0.1)
    cordova-open-native-settings (1.5.2)
    cordova-plugin-calendar (5.1.5)
    cordova-plugin-device-motion (2.0.1)
    cordova-plugin-email-composer (0.9.2)
    cordova-plugin-file (6.0.2)
    cordova-plugin-nativegeocoder (3.4.1)
    cordova-plugin-screen-orientation (3.0.2)
    cordova-plugin-vibration (3.1.1)
    cordova-plugin-x-socialsharing (5.6.8)
    cordova-sms-plugin (1.0.0)
    cordova-support-android-plugin (1.0.2)
    cordova-support-google-services (1.4.1)
    es6-promise-plugin (4.2.2)
    phonegap-nfc (1.1.2)
    phonegap-plugin-barcodescanner (8.1.0)

Platform(s)

  • Android

Current Behavior

I have set up firebase dynamic links as per the docs, and all works well on IOS - the appUrlOpen listener fires and captures the link itself.

On android, the dynamic links open the app correctly, however they listener never fires and as such I cant deal with the urls.

I have set up the app association corectly and the android stuio wizard confirms this. And I have also added the intent filters as described by the capacitor docs.

https://capacitorjs.com/docs/guides/deep-links

Expected Behavior

Opening a firebase dynamic link should open the app and the listener should emit the url - or any data in fact.

Code Reproduction

App.component.ts

  private initDeepLinks(): void {
    if (Capacitor.isPluginAvailable('App')) {
      App.getLaunchUrl()
        .then((res: AppLaunchUrl) => {
          console.log('APP LUANCH URL:');
          console.log(res?.url);
          if (!res?.url || res?.url === '') {
            this.store.setKey('openedWithDynamiclink', false);
          } else {
            if (res?.url.includes('com.app.ping://welcome/?code')) {
              this.store.setKey('openedWithDynamiclink', false);
            }
            this.logger.log('APP LAUNCH URL: ' + res?.url);
          }
        })
 
      App.addListener('appUrlOpen', (data: any) => {
        console.log('APP URL OPENED VEENT URL:');
        console.log(data?.url);

        Browser.close()
          .then()
          .catch(err => {
            console.error(err);
          })

        if (data?.url && data?.url !== '') {
          this.logger.log('APP OPENED WITH URL: ' + data?.url);
          this.deeplinks.consumeDynamicLink(data.url);
        }

      });
    }
  }

}

Activity - Android manifest:

` ``` <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:name="com.app.ping.MainActivity" android:label="@string/title_activity_main" android:theme="@style/AppTheme.NoActionBarLaunch" android:launchMode="singleTask">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:scheme="@string/custom_url_scheme"
                android:host="open" />
        </intent-filter>

        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:scheme="https"
                android:host="pingapp.page.link" />
            <data
                android:scheme="http"
                android:host="pingapp.page.link" />
        </intent-filter>




    </activity>`


### Other Technical Details

`npm --version` output: 6.14.5

`node --version` output: v14.0.0


### Additional Context
- I can see the app state listener emits correctly, and on launch the applaunchUrl is correctly logged.
- Firebase.json is correctly in the project
- I followed the capacitor update guides for android 


Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
pencilcheckcommented, Mar 9, 2022

I can reproduce this issue on the qemu, the app got into focus after deep link from browser but since the app was already opened the callback never get called

0reactions
ionitron-bot[bot]commented, Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic Angular (Capacitor) Auth0 SDK: App appUrlOpen event ...
all is Ok except that the event registred for callback is never triggered. App.addListener('appUrlOpen', ({ url }) => {. Thanks for help
Read more >
Android App Link not working with cordova with capacitor
I have everythign related to android app links, everything is setup via my ... the app opens but there is no data loaded...
Read more >
Ionic Forum - Latest topics - RSSing.com
URL Segment: 'menu/home' Error: Cannot match any routes. URL Segment: 'menu/home' at ... Next Capacitor App.getLaunchUrl() issue on Android device.
Read more >
Firebase dynamic link plugin on Capacitor - Ionic Forum
handleCodeInApp: true, android: { packageName: 'com.myapp.mobile', ... these plugins with Vue or have any idea why the event is not fired?
Read more >
Untitled
Duele una sacada de muela, Knight armour dark souls, 0x9f bug check, Speed of sound water ... Power plant fire, Mohamed fatima nem...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found