Search code examples
react-nativeios9react-native-ios

How to open default iOS apps from a React Native app?


I'm creating a React Native app and I'd like to be able to open default apps from it. Specifically:

  • Phone.app (clicking on a button in my app and opening iOS modal to call a specific number)
  • Apple Maps App (clicking on a button in my app and opening the Apple Maps with routing to specified target destination)

I understand I can open the system maps with

<TouchableOpacity
  onPress={() =>
    Linking.openURL(`geo:${latitude},${longitude}`)}>
  <Text>Open Map</Text>
</TouchableOpacity>```

and similarly call openURL("tel:" + telephone) for phone number. (I omit error handling in the code snippet purposefully.)

Next, it should be necessary to update ios/Info.plist to allow these application query schemes. I tried putting this into it:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>geo</string>
  <string>tel</string>
</array>

I'm still getting EUNSPECIFIED errors. I guess that maybe I'm not supposed to put the LSApplicationQueriesSchemes keys as geo and tel. I was, however, unable to find out what should go in there.

Thanks!


Solution

    1. If you are using simulator then only web URLs can be tested. Other URLs require actual device for testing.
    2. geo is android only.