Problem With Linking.getInitialURL()

#1

I’m using ExpoKit
When I open the app from http://ecocard.app, the app open end…

If app is Closed on Android

await Linking.getInitialURL() // --> 'ecocard://'

If app is Open on Android

await Linking.getInitialURL() // --> 'ecocard://'
Linking.addEventListener('url', ({url}) => console.log('Event', url) }) // --> 'http://ecocard.app'

If app is Open by Link when is Closed on Ios

await Linking.getInitialURL() // --> 'http://ecocard.app'

If app is Open by Link after Open By Icon on Ios

await Linking.getInitialURL() // --> 'ecocard://'
Linking.addEventListener('url', ({url}) => console.log('Event', url) }) // Never Triggered

AndroidManifest.xml

...
<data android:scheme="ecocard"/>
<data android:scheme="http" android:host="ecocard.app" />
<data android:scheme="https" android:host="ecocard.app" />
...

app.json

...
  "expo": {
    "sdkVersion": "28.0.0",
    "name": "Ecocard",
    "description": "Seja digital! Troque cartões de visitas com o Ecocard!",
    "slug": "ecocard",
    "icon": "./assets/img/icon-android.png",
    "privacy": "unlisted",
    "version": "2.4.1-dev-0.2",
    "platforms": [
      "ios",
      "android"
    ],
    "assetBundlePatterns": [
      "assets/fonts/*",
      "assets/img/*"
    ],
    ...
    "scheme": "ecocard",
...
0 Likes

#2

I try the same using ecocard:// scheme and The Same Behavior

On Expo Client using exp:// all works fine.

How can i make this works with http, https scheme?

What i’m missing??

0 Likes

#3

Hi @victorwads. Thanks for the report. Could you verify that the correct behaviors that you were expecting are:

If app is closed

await Linking.getInitialURL() // --> 'http://ecocard.app'

If app is open

await Linking.getInitialURL() // --> 'ecocard://'
Linking.addEventListener('url', ({url}) => console.log('Event', url) }) // --> 'http://ecocard.app'

?

0 Likes

#6

@esamelson, i solve it. Thank U for your help.

Ios

On Ios I remove one library - react-native-firebase-dynamic-links

Android

The issue is cause cause the on AndroidManifest.xml are on the wrong activity.

Before

    <activity
        android:name=".LauncherActivity" ...>
      <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="http" />
        <data android:scheme="https" />
        <data android:scheme="ecocard"/>
        <data android:host="ecocard.app" />
      </intent-filter>
    </activity>

After

    <activity
        android:name=".MainActivity" ...>
      <!-- START HOME INTENT FILTERS -->
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.LAUNCHER"/>
        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:scheme="ecocard"/>
        <data android:host="ecocard.app" />
      </intent-filter>
      <!-- END HOME INTENT FILTERS -->
    </activity>
1 Like

#7

@victorwads - glad you figured it out, thanks for letting us know!

1 Like

closed #8

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

0 Likes