[Android 13] Using OpenSettings, app restarts when user returns to the app
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
- Open the app on an Android 13 device
- Press the
Open settingsbutton - Settings of the app opens, then switch off all notifications permissions
- Press back button to return to the app
- App will restart
Reproducible sample code
import {openSettings} from 'react-native-permissions'
const handlePermissionsChange = useCallback(async()=>{
await openSettings()
},[])
<Button label="Open settings" onPress={handlePermissionsChange}/>
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 @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!
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.
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 Indeed, that might happen.
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.
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.
Experiencing the issue on all iPhones as low as version 15.6 with the camera permission
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
Hello guys, any update here?
im also experiencing this issue both android and ios
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.
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 That seems undocumented, at least in the declared changes. It might be an Android bug, feels free to open an issue on their tracker.
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 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.