Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 commented Oct 31, 2020

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

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

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

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

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

Xcode

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

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

Xcode

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

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

Xcode

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

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

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

Loading

@daisukenagata
Copy link
Author

daisukenagata commented Oct 31, 2020

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

Loading

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