7

How to open other apps (Gmail, Camera) from ReactNative. How can I pass data from current scene to other app?

4 Answers 4

1

I found this npm library react-native-app-link which can open other apps. This is based on deep linking, if you have any deep links then this library can help. This doesn't open apps just by giving the android package name or ios app id.

https://github.com/FiberJW/react-native-app-link

Sign up to request clarification or add additional context in comments.

1 Comment

Is there any other way to open the app without deep link URL?
0

you can mange opening other apps using Linking

2 Comments

const googlePlayLink = 'play.google.com/store/apps/details?id=com.whatsapp&hl=en' const app = 'whatsapp://app' Linking.openURL(app).catch(err => { console.log('whatsapp is not installed', err) Linking.openURL(googlePlayLink) })
Is there any other way to open the app without a deep link URL?
0

Code sample for opening the dialer

const urlToOpen = 'tel:1234567890';
Linking.openURL(urlToOpen);

You can refer to the official doc here, it just predefines some applications, which can be opened.

However, if the question is about to open just about any application, I hope there is no solution till now.

Comments

0

react-native-app-link has some redundant config (e.g. appStoreLocale parameter), so I wrote my own realization using their code:

import { Alert, Platform, ToastAndroid } from 'react-native';

const isIos = Platform.OS === 'ios';

const showNotification = (text) => isIos
  ? Alert.alert(text)
  : ToastAndroid.show(text, ToastAndroid.SHORT);

const openApp = ({ url, appStoreId, playMarketId, name }) => {
  Linking.openURL(url).catch(err => {
    if (err.code === 'EUNSPECIFIED') {
      Linking.openURL(
        isIos
          ? `https://apps.apple.com/app/id${appStoreId}`
          : `https://play.google.com/store/apps/details?id=${playMarketId}`,
      );
    } else {
      showNotification(`Can't open ${name} app`);
    }
  });
};

It tries to open the app by the specified link, and if the user doesn't have such one, it opens its page in AppStore or Play Market.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.