react-native-permissions icon indicating copy to clipboard operation
react-native-permissions copied to clipboard

[Android 13] Using OpenSettings, app restarts when user returns to the app

Open mahdieh-dev opened this issue 3 years ago • 16 comments

Bug summary

We are using a button in the app that lets the users open the app settings to control the push notification permissions. For this purpose, we are using the function openSettings from this library. Using Android 13, when the user opens the settings, switches off the push notification permissions, and returns to the app, the app restarts. But when the user switches the push notification permission on and returns to the app, the app doesn't restart and works normally (like backgrounding the app and making it active again, no restart). I researched about it, but couldn't find any solutions for it, could you help us, please?

Library version

3.6.1

Environment info

This issue has happened in a physical device with Android 13
S22 Utral, OneUI 5.0

Steps to reproduce

  1. Open the app on an Android 13 device
  2. Press the Open settings button
  3. Settings of the app opens, then switch off all notifications permissions
  4. Press back button to return to the app
  5. App will restart

Reproducible sample code

import {openSettings} from 'react-native-permissions'



const handlePermissionsChange = useCallback(async()=>{
  await openSettings()
},[])

<Button label="Open settings" onPress={handlePermissionsChange}/>

mahdieh-dev avatar Feb 02 '23 09:02 mahdieh-dev

Hi @mahdieh-dev 👋

I just gave it a try using the example app and my Pixel 4a (Android 13) and I cannot reproduce this. Are you using a real device? Can you try the example app to confirm that's not related to your app code?

zoontek avatar Feb 03 '23 09:02 zoontek

Hi @mahdieh-dev 👋

I just gave it a try using the example app and my Pixel 4a (Android 13) and I cannot reproduce this. Are you using a real device? Can you try the example app to confirm that's not related to your app code?

Hi @zoontek! It was a real device, I couldn't also reproduce it on other Android phones and emulators. It's a good idea! I will make a build from the example app and give it to my colleague to test it and will let you know about the results. Thanks!

mahdieh-dev avatar Feb 03 '23 14:02 mahdieh-dev

I've also being experiencing this issue. I've tested on Android 13 and also Android 11 but my issue is not for notifications but for location settings. When the user leaves the app and changes a location setting, my app reloads.

astridlujo avatar Feb 16 '23 14:02 astridlujo

Hi @mahdieh-dev

There's a possibility that the phone you tested has a low ram and it ran out of swap memory. A few android phones don't have swape memory support and a few have very limited space for that. So when it ran out of memory, it kills non-active applications.

Shoukat488 avatar Feb 18 '23 15:02 Shoukat488

@Shoukat488 Indeed, that might happen.

zoontek avatar Feb 19 '23 13:02 zoontek

I can confirm this for iOS 16 AND Android 11 for the CAMERA permissions. Blocked notification requests work just fine, but they seem to be a different pair of shoes entirely.

This had been working perfectly before, so this might be due to some version update of RNPermissions or RN itself (?) – I will try to investigate.

iOS simulator & real device; Android real device. RAM does not play into this; tried several times without any other apps open and definitely enough RAM (iPhone 13 Pro, Samsung S10).

Currently on 3.8.0, RN 0.71.6.

Peeeep avatar Apr 20 '23 10:04 Peeeep

I'm having the same issue.

Samsung A52S / Android 13

But it is working fine on my Iphone 13 / iOS 16.3.1

Has anybody found a solution or maybe a workaround to get more clarity of whats going on?

Cheers.

EduuLucas avatar May 02 '23 08:05 EduuLucas

Experiencing the issue on all iPhones as low as version 15.6 with the camera permission

cheymonty avatar May 12 '23 21:05 cheymonty

Can confirm this only for the Camera settings on two physical devices. Changing notifications does not cause a restart.

RN: 71.8

iOS: Apple 12, 16.0.3 android: Galaxy A13, v 12

ABukSwienty avatar May 16 '23 12:05 ABukSwienty

Hello guys, any update here?

quannq-vvt avatar Jun 09 '23 09:06 quannq-vvt

im also experiencing this issue both android and ios

ghost avatar Jun 29 '23 23:06 ghost

I don't think this is a bug, just something new in Android now. A lot of apps are not rechecking permissions after startup, forcing the app to reboot is a solution. Apple does that on iOS too.

zoontek avatar Jul 11 '23 20:07 zoontek

I am experiencing this with FINE Location, Even though its granted via device settings, The App takes some time to reflect the permission in runtime. Otherwise, I have to kill the App.

@zoontek - It would be really great if you could share some documentation for this new behaviour in Android.

AmalMenachery avatar Jul 25 '23 11:07 AmalMenachery

@AmalMenachery That seems undocumented, at least in the declared changes. It might be an Android bug, feels free to open an issue on their tracker.

zoontek avatar Jul 25 '23 11:07 zoontek

I think the behaviour described in the original issue is documented by Android docs here: https://developer.android.com/training/permissions/requesting#app_process_terminates_when_permission_revoked

As with any permission, if the user revokes your app's one-time permission, your app's process terminates.

So when revoking permissions, the app will terminate, leading to a fresh start.

I haven't looked for matching iOS docs, but I suspect they do the same thing. Accordingly I don't think there's a bug and nothing this library could address.

jzaefferer avatar Jul 25 '23 13:07 jzaefferer

@jzaefferer iOS has done that for quite a long time already. You are right, this is not an issue with the library itself, I'm closing this.

zoontek avatar Jul 26 '23 08:07 zoontek