Last active
February 27, 2021 22:43
Star
You must be signed in to star a gist
FirebaseAppCrashlytics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func FirebaseAppCrashlytics() { | |
FirebaseApp.configure() | |
Crashlytics.crashlytics() | |
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true) | |
let userInfo = [ | |
NSLocalizedDescriptionKey: NSLocalizedString("The request failed.", comment: ""), | |
NSLocalizedFailureReasonErrorKey: NSLocalizedString("The response returned a 404.", comment: ""), | |
NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString("Does this page exist?", comment: ""), | |
"ProductID": "ProductID", | |
"View": "Name" | |
] | |
let error = NSError.init(domain: NSCocoaErrorDomain, | |
code: -1001, | |
userInfo: userInfo) | |
Crashlytics.crashlytics().record(error: error) | |
Crashlytics.crashlytics().setUserID("user_id") | |
Crashlytics.crashlytics().checkForUnsentReports { hasUnsentReport in | |
let hasUserConsent = false | |
// ...get user consent. | |
if hasUserConsent && hasUnsentReport { | |
Crashlytics.crashlytics().sendUnsentReports() | |
} else { | |
Crashlytics.crashlytics().deleteUnsentReports() | |
} | |
} | |
// Detect when a crash happens during your app's last run. | |
if Crashlytics.crashlytics().didCrashDuringPreviousExecution() { | |
// ...notify the user. | |
print("// ...notify the user.") | |
} | |
} |
上記は簡易的にCrashlytics送信する方法です。詳細はドキュメントを確認してください。
ログを取得する場合は、fatalError()を明示的に出力して、再度アプリケーションを起動させます。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://firebase.google.com/docs/crashlytics