skip to Main Content

how to redirect to app settings in react native for android 12 only?

NativeModules.OpenSettings.openNetworkSettings(() => null);

i can’t use that code right now

import { openSettings } from 'react-native-permissions';
openSettings();

this also not working for me

3

Answers


  1. have you tried this

    const Screen = () => (
      <Button
        title="Open Settings"
        onPress={() => {
          Linking.openSettings();
        }}
      />
    );
    

    don’t forget to import

    import { Button, Linking } from "react-native";
    
    Login or Signup to reply.
  2. First you have go to the official documentation of React Native there
    you find the solution of this question.

    Documentation of React Native Linking

    Code:

    <TouchableOpacity
                onPress={() => {
                  Linking.openSettings();
                }}
                style={{
                  paddingHorizontal: 80,
                  paddingVertical: 10,
                  backgroundColor: '#326A81',
                }}>
                <Text style={{color: 'white'}}>Open Setting</Text>
              </TouchableOpacity>
    
    Login or Signup to reply.
  3. The below should work for both android and ios

    import { Linking, Platform } from 'react-native';
    
    
    const handleOpenSettings = () => {
        if (Platform.OS === 'ios') {
          Linking.openURL('app-settings:');
        } else {
          Linking.openSettings();
        }
    };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search