1

I have some links that should redirect to specific pages in my app; I followed the instructions on https://reactnavigation.org/docs/5.x/deep-linking/ and it works fine on previous Android versions, but on version 13, they all redirect to the Home page.

AndroidManifest.xml:

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:windowSoftInputMode="adjustPan"
        android:screenOrientation="portrait"
        android:exported="true"
        android:launchMode="singleTask">
          <intent-filter android:autoVerify="true" tools:targetApi="m">
              <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="campanha.soustix.com.br"/>
          </intent-filter>
          <intent-filter>
              <action android:name="br.com.soustix.NOTIFICATIONPRESSED" />
                  <category android:name="android.intent.category.DEFAULT" />
          </intent-filter>
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>

deepLinkRoutes.rs:

export const linkingConfig = {
  config: {
    screens: {
      Home: {
        screens: {
          HomePage: 'app',
          MyExchanges: 'vouchers',
          Explore: 'explore'
        }
      },
      ProductDetail: 'product/:id',
      P2PPresentation: 'p2p',
      MGM: 'invitefriends',
      Extract: 'extract',
      MyAccount: 'myaccount',
      JoinStix: 'joinstix',
      Login: 'iam',
      Catalog: 'catalog',
      PartnerDetail: 'iupp',
      Search: 'categories/:rootCategory'
    }
  }
};

App.tsx:

import { linkingConfig } from './src/config/deepLinkRoutes';
//rest of the code
<NavigationContainer linking={{ prefixes: ['
https://campanha.soustix.com.br/redirect'] }} >

I tried to run adb shell am start -W -a android.intent.action.VIEW -d "https://campanha.soustix.com.br/redirect/p2p" br.com.soustixp but I just get error: activity not started, unable to resolve intent { act=android.intent.action.view dat=https://campanhasoustix.com.br/... flg=0x10000000 pkg=br.com.soustix } Also tried adding android:pathPrefix="/redirect/p2p" to the data tag but that didn't work either. Please, what am I missing?

AmerllicA
  • 29,059
  • 15
  • 130
  • 154
  • Instead of URL, try to use `schema` and then try it again. If schema works then seek to find why the URL doesn't work – AmerllicA Aug 28 '23 at 16:25
  • @AmerllicA could you please give me more details on how to try that? Thank you – João Raffo Aug 28 '23 at 16:49
  • Like [docs](https://reactnavigation.org/docs/navigation-container/#linking) explains, use a schema for your `prefixes`, eg: `prefixes: ['joaoraffo://'],`. Then for testing the deep link in the browser address bar type: `joaoraffo://some-page-name`. it should open your app, or ask you to open it. if it works, then try to add a web address prefix, if it works try the above address. step by step fix your problem. – AmerllicA Aug 28 '23 at 16:56
  • And by this line: `` I guess you haven't understood the deep linking pretty well. you should use schema and a simple website name. then the App will be opened by schema or a link that contains that prefixes address. Inside the app you can catch up the rest of address and try to use it. – AmerllicA Aug 28 '23 at 17:01
  • @AmerllicA thank you so much. It's still not working on the browser, but it works when I run adb shell am start -W -a android.intent.action.VIEW -d "https://campanha.soustix.com.br/redirect/extract" br.com.soustix.app – João Raffo Aug 28 '23 at 18:26
  • Leave the browser, I said browser for schema, not the web link. Definitely, a browser should open the web. So that's ok. Which of my comments helped you? I want to post it as answer. – AmerllicA Aug 28 '23 at 18:44
  • The second one. – João Raffo Aug 28 '23 at 19:29

1 Answers1

0

The way of linking definitions and way of using them isn't correct. Based on react navigation docs you can define like the following for example:

<NavigationContainer
  linking={{ prefixes: ['joaoraffo://'] }}
>
  ~~~
</NavigationContainer>

Then the App will be opened by schema or a link that contains that prefix address. Inside the app, you can catch up with the rest of the addresses and try to use it

AmerllicA
  • 29,059
  • 15
  • 130
  • 154