Home > Net >  Quit an app (swift) programmatically without crash log in Firebase
Quit an app (swift) programmatically without crash log in Firebase

Time:07-22

I know this is against Apple’s Human Interface Guidelines but I need to quit an app programmatically but I don’t want to use fatalError(…) because that reports a crash in Firebase’s Crashlytics.

I’m considering replacing fatalError(…) with exit(…) but will that still produce a crash log in Firebase?

Thanks for any help.

CodePudding user response:

I believe fatalError(_:file:line:) should be used only if the application enters an unknown state, a state it doesn't know how to handle. Remember that your application will crash and burn if it throws a fatal error and eventually reporting a crash in Firebase Crashlytics.

If you use exit(0), your application will be rejected due to the following reason:

We found that your app includes a UI control for quitting the app. This is not in compliance with the iOS Human Interface Guidelines, as required by the App Store Review Guidelines.

To avoid any such rejections, suspend the application using the following code snippet.

UIApplication.shared.perform(#selector(NSXPCConnection.suspend))

This line of code is in compliance with the iOS Human Interface Guidelines and your app won't be rejected.

  • Related