How to open other application from my application
Asked Answered
B

2

2

I am writing code to launch other applications from my react native application for android and ios.

Using Linking form react native I am able to redirect to Play Store/App Store but

How can I launch App if it's already installed?

* I am getting the list of the app's from server

enter image description here

Linking.openURL('https://play.google.com/store/apps/details?id=com.example.myapp&hl=en')

Is there any way that I can launch the app if it's installed else redirect to App store/play store with respect to the platform?

Reference:react-native-app-link

Bois answered 14/11, 2019 at 12:14 Comment(4)
I don't understand what you want! You want to open other apps it's already installed in your app ?Ahders
It depends upon which app you wants to open and what data you have to pass in that app.Suppose you want to open map app from your RN app .with custom latitude&longitude values.For that you can use this one var scheme = Platform.OS === 'ios' ? 'maps:' : 'geo:'; var url = scheme + ${lat},${lng}; Linking.openURL(url); Import {Linking} from "react-native"Demonolatry
@AbdulBasit I just want to launch the app, I have app with name Sagar and package name com.sagar so how can I go for sameBois
Linking.canOpenURL(yourApp ).then(supported => { if (supported) { Linking.openURL(yourApp); } else { alert("sorry invalid url"); }Ahders
B
4

After many searches I have found an alternative for android without deep link URL is to use the native module react-native-intent-launcher to launch another app using package-name.

You can call the native function startActivity in react-native to do something with Intent which can only be solved with android native code.

Looking for iOS solution without deep link URL if any lead please update here

Once I found I will update Here

Thank you

Bois answered 19/11, 2019 at 5:42 Comment(0)
H
1

Your other app need to handle Deeplinking. If that's not already the case, have a look here for Android and here for iOS.

This will allow you to have your app's own URL scheme, for example testapp://example

Then you can simply use the Linking API, but instead of opening a HTTP URL, you can use you Deeplink URL scheme defined previously.

Linking.openURL('testapp://example');
Hilarity answered 14/11, 2019 at 13:39 Comment(4)
can we access the random app if only having app name and package name using react-nativeBois
@Sagar, sadly you can't. It has to be a URL as you can see here: facebook.github.io/react-native/docs/linking.html#openurl the only way to get a URL for your app is through deep linking.Hilarity
is there any way to achieve with react nativeBois
Without updating the "target" app no. The only other alternative is to open the Store as you did.Hilarity

© 2022 - 2024 — McMap. All rights reserved.