Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Settings App from another App in iOS - React Native

I'm going through the docs in React Native and can only find navigating to external links from the app I am in.

I want to be able to navigate to the Settings app (more specifically to the privacy > location services page) but, can not seem to find the necessary information on it. There is the native iOS way of doing it which I am trying to replicate through React Native.

Is this possible?

I have tried the following to detect if there is a Settings URL. The console logs that the Settings url works however, it does not navigate to that page.

Update: thanks to @zvona I am now navigating to the settings page but not sure how to get to a specific deep link.

Linking.canOpenURL('app-settings:').then(supported => {
            
    console.log(`Settings url works`)
    Linking.openURL('app-settings:'
}).catch(error => {
    console.log(`An error has occured: ${error}`)
})
like image 516
Simon Avatar asked Aug 22 '16 14:08

Simon


People also ask

How do I open Settings app in React Native?

Opening a settings app in React Native is so simple, we can open it directly in React Native using Linking. Linking API provides an openSettings() function which will redirect to Settings App.

How do I open app settings?

From the Home screen, tap the Apps icon (in the QuickTap Bar) > the Apps tab (if necessary) > Settings .


3 Answers

You can access settings of the application with: Linking.openURL('app-settings:');

But I don't know (yet) how to open a specific deep-link.

2021 update use:

Linking.openSettings();

otherwise your app will be rejected due use of non-public URL scheme

like image 108
Samuli Hakoniemi Avatar answered Oct 07 '22 13:10

Samuli Hakoniemi


I successfully opened the settings by the code below, hope it's helpful :)

Linking.canOpenURL('app-settings:').then(supported => {
  if (!supported) {
    console.log('Can\'t handle settings url');
  } else {
    return Linking.openURL('app-settings:');
  }
}).catch(err => console.error('An error occurred', err));

Reference: https://facebook.github.io/react-native//docs/linking.html

like image 33
tokinonagare Avatar answered Oct 07 '22 12:10

tokinonagare


Since React Native version 0.59 this should be possible using openSettings();. This is described in the React Native Linking documentation. Although it did not work for me. When I tried quickly I saw a _reactNative.Linking.openSettings is not a function error message.

Linking.openSettings();
like image 12
matthew Avatar answered Oct 07 '22 11:10

matthew