Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crashes in background while changing permission - swift [duplicate]

Tags:

ios

swift

iphone

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)
        })
    }
}))

This does work in so far as it opens the settings, but 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 solve this?

like image 345
James Avatar asked May 15 '17 08:05

James


1 Answers

Your app is not crashing its just forced to restart by iOS with new privacy settings. So when you change the camera permission then it means privacy policy changed, so app will be killed if its attached to debugger else it will relaunch.

Also, Not only camera permission If the user at some point changes the Address Book, Calendars, Reminders, Camera, or Photos permissions, iOS will SIGKILL the app. (it's default behaviour of iOS)

like image 103
Jaydeep Vora Avatar answered Oct 15 '22 16:10

Jaydeep Vora