I am using below code for POST_NOTIFICATIONS in a React Native app but every time it return never_ask_again

23 views Asked by At
const requestNotificationPermission = async () => {
  try {
    if (Platform.OS === 'android') {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
      );
      console.log({granted});
      
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        console.log('Notification permission granted');
      } else {
        console.log('Notification permission denied');
        // Linking.openSettings();
      }
    }

  } catch (error) {
    console.error('Error requesting notification permission:', error);
  }
};

I have already included in AndroidManifest file

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
googlePlayServicesVersion = "21.0.1"

Running on Android 11 physical device I have checked many solutions but no luck. Thanks

0

There are 0 answers

Related Questions in REACT-NATIVE-PERMISSIONS