Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: React native open an app from another app?

I am trying to open a another app(https://play.google.com/store/apps/details?id=com.inova.velocity) from my app. But there are all the tutorial just redirecting url to playstore only.(I found a github link(https://github.com/FiberJW/react-native-app-link) and it opens the app for iOS only, but for Android it is redirecting to playstore). Is there is any way to solve this problem?

Linking.canOpenURL('market://details?id=com.inova.velocity')
      .then((canOpen) => {
        if (canOpen) { 
          console.log('open app'); 
          return Linking.openURL('market://details?id=com.inova.velocity')
                 };
        }).catch(err => console.log('An error occurred', err));
like image 882
ios newbie Avatar asked Jul 08 '26 05:07

ios newbie


1 Answers

Yes your code is correct. But you have used playstore url, instead of schema url. you have to set the schemaUrl which you can get it from relevant app developer. if there is no schema url set for the that app you can't open it. after you get the SchemaUrl you can use your code. like below.


Linking.canOpenURL(SchemaUrl).then(supported => {
             if (supported) {
               console.log('accepted');
               return Linking.openURL(SchemaUrl);
             } else {
               console.log('an error occured');
             }
           }).catch(
             err => console.log('an error occured');
           );

like image 164
Manojkanth Avatar answered Jul 09 '26 20:07

Manojkanth