expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
470 stars 101 forks source link

Error when trying to open a link to a nonexistent page (expo sdk 50) #246

Open goldfishdevs opened 3 months ago

goldfishdevs commented 3 months ago

Summary

I am trying to integrate my branch.io project with my react native expo project. I am using expo SDK 50 with @config-plugins/react-native-branch 6.0.0

When I click on a link, the app opens, but I don't know why it always goes to a nonexistent page. And i am using expo-router

Screenshot 2024-07-30 at 08 46 29 Screenshot 2024-07-30 at 08 46 52

Config Plugin

@config-plugins/react-native-branch

What platform(s) does this occur on?

Android, iOS

SDK Version

50.0.7

Reproducible demo

Those are the packages used in my package.json file

"expo": "^50.0.7", "react-native-branch": "6.0.0", "@config-plugins/react-native-branch": "7.0.0",

Page redirected when opening the app from the link IMG_4603

goldfishdevs commented 3 months ago

Any help please ?

NicolasRecomiendApp commented 2 months ago

Hi @goldfishdevs, are you using expo router?

goldfishdevs commented 2 months ago

Yes. i am using it

NicolasRecomiendApp commented 2 months ago

So, then you don't have to handle anything for android, just configure the path to navigate directly to the concrete screen on branch platform -> /home -> it should do a navigation to your home screen.

In iOS you have to capture the link and then select the correct property to handle the navigation.

This is an example of what could you do on iOS

try {
      if (Platform.OS === 'ios' && branch != undefined) {
        branch?.subscribe(({ error, params }) => {
          if (error) {
            console.error('Error from Branch: ' + error);
            return;
          }
          console.log('Arrives to branch');
          // params will contain link data
          console.log('Branch Params: ' + JSON.stringify(params));
          console.log(params['$deeplink_path']);
          const ruta = params['$deeplink_path']
            ? 
              params['$deeplink_path']
            : 
            params['$ios_deeplink_path']
            ? 
              params['$ios_deeplink_path']
            : 
              params['+non_branch_link'];
          console.log('RUTA!!!', ruta);
          if (ruta != undefined) {
            //@ts-ignore
            router.replace(ruta);
          }
        });
      }
    } catch (error) {
      console.error('Erron on branch deeplink', error);
    }
goldfishdevs commented 1 month ago

So, then you don't have to handle anything for android, just configure the path to navigate directly to the concrete screen on branch platform -> /home -> it should do a navigation to your home screen.

In iOS you have to capture the link and then select the correct property to handle the navigation.

This is an example of what could you do on iOS

try {
      if (Platform.OS === 'ios' && branch != undefined) {
        branch?.subscribe(({ error, params }) => {
          if (error) {
            console.error('Error from Branch: ' + error);
            return;
          }
          console.log('Arrives to branch');
          // params will contain link data
          console.log('Branch Params: ' + JSON.stringify(params));
          console.log(params['$deeplink_path']);
          const ruta = params['$deeplink_path']
            ? 
              params['$deeplink_path']
            : 
            params['$ios_deeplink_path']
            ? 
              params['$ios_deeplink_path']
            : 
              params['+non_branch_link'];
          console.log('RUTA!!!', ruta);
          if (ruta != undefined) {
            //@ts-ignore
            router.replace(ruta);
          }
        });
      }
    } catch (error) {
      console.error('Erron on branch deeplink', error);
    }

My problem is that every time I open the app from the config link from branch.io, I always get to the not found page. I check and found current pathName "/ID_link_banch_IO". But if I link in the form "app://" there will be no error. so what I see you're talking about here is configured internally.

NicolasRecomiendApp commented 1 month ago

Have you correctly configured branch plugin on App.json? "plugins": [ [ "@config-plugins/react-native-branch", { "apiKey": "key_live_your_key_live_here", "iosAppDomain": "your_ios_app_domain" } ], ]

goldfishdevs commented 1 month ago

Have you correctly configured branch plugin on App.json? "plugins": [ [ "@config-plugins/react-native-branch", { "apiKey": "key_live_your_key_live_here", "iosAppDomain": "your_ios_app_domain" } ], ] Screenshot 2024-10-08 at 14 05 45 Yes, I have configured it in the app.config.json file