Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App is forced to restart by iOS with new privacy settings

if the user changes the Camera permission, the app crashes in the background with Message from debugger: Terminated due to signal 9 .

They can now open up the app and the permission is correct, but they need to start from the beginning. Does anyone know how to fix this?

I need to prompt users to change camera permissions for my app via a UIAlertController. The alert has the following action:

alert.addAction(UIAlertAction(title: "Open Settings", style: .default, handler: { (action) -> Void in

    guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
        return
    }

    if UIApplication.shared.canOpenURL(settingsUrl) {
        DispatchQueue.main.async(execute: {
            UIApplication.shared.openURL(settingsUrl)
        })
    }
}))
like image 327
Hardik Darji Avatar asked Nov 22 '18 08:11

Hardik Darji


People also ask

Why does my app restart whenever I come back to it from another app iOS?

If you leave and use another app, the other app may use too much RAM for your phone to keep both apps open, so it has to shut one down, causing it to need to reload when you go back to it.

Why does my iPhone keep resetting apps?

Apps are only allowed to stay open in the background for a few minutes (this saves RAM), so if the developer doesn't have the app save where you were last, the app will reset to its start page. So no, you can't do anything about this. This is why you don't really need to close your apps in the app switcher.

How do I stop iOS apps from resetting?

Tap on Settings on your iPhone or iPad > General > Background App Refresh > toggle Background App Refresh to Off.


1 Answers

This is not a problem of your application. Its just the way apple designed iOS. iOS will terminate the application when user change certain permissions of it.

Actually you will get a SIGKILL message but no Crash log when toggling settings. In this situation even applicationWillTerminate not get called!

So the answer is you can't fix it.

Look at page 24 of this slide

like image 53
Sepehr Behroozi Avatar answered Sep 27 '22 16:09

Sepehr Behroozi