Skip to content

Instantly share code, notes, and snippets.

@DaisukeNagata
Last active February 27, 2021 22:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DaisukeNagata/082955c365f263bd9c17a76d5041153f to your computer and use it in GitHub Desktop.
FirebaseAppCrashlytics
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.")
}
}
@DaisukeNagata
Copy link
Author

@DaisukeNagata
Copy link
Author

スクリーンショット 2020-11-01 3 24 54

@DaisukeNagata
Copy link
Author

スクリーンショット 2020-11-01 3 24 23

@DaisukeNagata
Copy link
Author

DaisukeNagata commented Oct 31, 2020

Xcode

スクリーンショット 2020-11-01 4 27 34

@DaisukeNagata
Copy link
Author

Xcode

スクリーンショット 2020-11-01 4 26 46

@DaisukeNagata
Copy link
Author

Xcode

スクリーンショット 2020-11-01 4 29 20

@DaisukeNagata
Copy link
Author

上記は簡易的にCrashlytics送信する方法です。詳細はドキュメントを確認してください。

@DaisukeNagata
Copy link
Author

ログを取得する場合は、fatalError()を明示的に出力して、再度アプリケーションを起動させます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment