1

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.

Pavol Ho
  • 23
  • 2

1 Answers1

1

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.

NaveedUlHassan5
  • 235
  • 1
  • 14
  • Thank you! Do you know if the method you provided will be reported as crash by Crashlytics? (Sorry I can’t test it in Firebase right now). – Pavol Ho Jul 21 '22 at 07:48
  • No it will not be reported because you're quitting an app and not crashing it. Two separate things. Also accept the answer if it was useful for you. – NaveedUlHassan5 Jul 21 '22 at 07:57
  • this appeared as more of a "enterBackground" than "appWillTerminate." Didn't see any crashes in crashlytics but don't think this is the answer the OP (Pavol) is looking for – bubbaspike Sep 01 '22 at 16:23