non-fatal error functionality of Crashlytics - ios

I was testing the non-fatal error functionality of Crashlytics and can't seem to get the Logs and Keys appear in Crashlytics Dashboard When I called bellow lines in AppDelegate and added logs in one of my ViewController.
let error = NSError(domain:"XYZ", code: Int(1.0), userInfo: nil)
Crashlytics.sharedInstance().recordError(error)
But it's working if i add above two lines in my ViewController button Click and add logs in it.. it gives me every log that i added in my application.
But adding in button click seems weird is there any way to do in AppDelegate or any common area?

Mike from Fabric here. This is the order that we process information - crashes, non-fatal exceptions or errors, then at the same level - custom keys, logs and user identifiers. If you capture a custom key or log just before the error then there may not be enough time to write it to disk before we capture the error. Also, one thing to note is that logs and keys are only sent if a crash or non-fatal exception occurs.

Related

How to disable crash report popup from crashlytics

I want to disable this crash popup emitted from the crashlytics framework, but still send the crash.
I've seen in the doc that you can filter the dispatch using "CrashlyticsDelegate" but I can't figure out how to shut down this. (also the doc last update is Last updated: 2017-01-20, am I missing something here o.O)
Also using strings I see some methods such as:
alertWithTitle:message:delegate:cancelButtonTitle:otherButtonTitle:
setupAndDisplayAlertWithTitle:message:cancel:send:alwaysSend:report:
So the questions:
Is it at least possible to disable it?
If it is, how?
I wonder if it comes from an older version of crashlytics, explaining maybe why I'm not able to find it in the doc~
EDIT: I tested the delegate's methods provided to intercept the crash before sending it
Using - (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report; the doc says (in the header since the internet doc isn't up to date):
it is not called synchronously during initialization
it does not give you the ability to prevent the report from being submitted
the report object itself is immutable
So this one doesn't provide any way of removing the popup.
Using - (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report completionHandler:(void (^)(BOOL submit))completionHandler; the doc says (in header again):
Invoking completionHandler with NO will cause the detected report to be deleted and not submitted to Crashlytics. This is useful for implementing permission prompts, or other more-complex forms of logic around submitting crashes.
Can't disable the popup here either.
Moreover I don't see what is the point of having a "permission prompt" like they say if you can't remove theirs :(
You can disable the privacy dialog pop-up in the app settings page
https://docs.fabric.io/android/crashlytics/advanced-setup.html#use-the-privacy-dialog
Here is a screenshot of where it hides:

How to report a non-fatal exception with Firebase crash on iOS?

How to report on iOS a non-fatal exception using Firebase Crash Reporting? In Android, we can do something like this:
FirebaseCrash.report(new Exception("My first Firebase non-fatal error on Android"));
You can now log non-fatal exceptions in Firebase Crashlytics
The accepted answer is therefore no longer correct. Non-fatal exceptions can be logged with the following Firebase Crashlytics method:
Crashlytics.crashlytics().record(error: error)
From the documentation:
This allows you to record a non-fatal event, described by an NSError object. These events will be grouped and displayed similarly to crashes. Keep in mind that this method can be expensive. Also, the total number of NSErrors that can be recorded during your app's life-cycle is limited by a fixed-size circular buffer. If the buffer is overrun, the oldest data is dropped. Errors are relayed to Crashlytics on a subsequent launch of your application.
Example usage:
let userInfo: [String: String] = [
"deviceId": "someDeviceId",
"localizedDescription": yourException.localizedDescription,
"anotherKey": "anotherValue"
]
let domain = "METHOD: some/domain/that/just/had-an-exception"
let code = 404
let error = NSError(domain: domain, code: code, userInfo: userInfo)
Crashlytics.crashlytics().record(error: error)
Where domain is some pretty identifier for use in Firebase (e.g. method + request path), code is the status code of the exception (a 404 here), and userInfo additional data are converted to key-value pairs and displayed in the keys/logs section within an individual issue.
Note: Logged errors are grouped by the NSError domain and code (unlike fatals, which are grouped in Firebase by their stack trace).
Example output in Firebase Console > Crashlytics:
Issue details page in the console (showing userInfo key-value pairs):
Jen's answer is correct. There are a few alternatives you can consider, though:
Log a Firebase Analytics event. While this won't give you all the stack tracey goodness you get from Firebase Crash Reporting, you can at least keep track of how often a particular exception is happening over time.
Use the FIRCrashMessage() method to make note of any errors that occur in your app. You will only see these log methods in crash reports that end up getting reported to Firebase Crash Reporting, but given that errors often lead to crashes, this isn't such a bad idea.
Try Crashlytics. They have a reportError() method that's specifically designed for reporting non-fatal errors. It's fine to use Crashlytics for your crash reporting while continuing to use other features of Firebase within your app -- it's all the same parent company these days. :)
According to the documentation, you can only report fatal errors on iOS at this time.

MobileFirst Platform Operational Analytics - Log Screen Visit Times and Custom Crash Details

I'm developing an iOS app using MFP 7.0.
Each screen (i.e., view controller) has a unique ID, and I am supposed to use Operational Analytics to send the following info to the server:
How long the user spent on each screen
On which screen the app crashed
Regarding #1, I guess I am supposed to use WLAnalytics's
- (void) log:(NSString*)message withMetadata:(NSDictionary*)metadata;
(right?)
How can I manage #2? Should I just log the screen ID (using the method above) every time a transition occurs, and expect the last logged id to be passed when the crash log is sent? Or is there any other way to add custom information to crash logs?
Correct you can follow Custom Data, Custom Charts here https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.0/moving-production/operational-analytics/
Crash log is detected and sent automatically post crash next time app is started. There is no way to add custom data to that report. Usually the place where the error happen could be deduced form the crash data stack, if this is not sufficient, you can apply the technique you are describing.

An Objective-C message was sent to a deallocated 'UIActivityIndicatorView' object

When running my app on device, it crashes right when I initiate my AvPlayer to stream an mp3. However, it works fine on simulator.
I have tried to run it through Zombie and I get the following error message when it crashes : "An Objective-C message was sent to a deallocated 'UIActivityIndicatorView' object (zombie) at address: 0x108c020e0"
I am using an Activity indicator in previous scenes but I have tried to remove it completely, leaving no line of code mentioning any UIActivityIndicatorView and I still get the same error.
Any idea of how to deal with this? Can it be linked to the system activity indicator displayed the status bar?
Many thanks for your help
It's a crash because of abusing appearance API not as documenting (setting a property not marked with UI_APPEARANCE_SELECTOR).
For reference, see here.

Catching the crash log on iOS

The main idea is to catch the crash log (or the reason of the error) and send it to a server.
I know that iTunes does log the crashes from the users' devices but I need to find if there's a way to get it and store it on our server.
I was trying "PlCrashReporter" and i finished implementing it (as they did on this link https://www.plcrashreporter.org/documentation/api/v1.0/example_usage_iphone.html).
Problem
The function applicationDidFinishLaunching is not called when the crash occurs.
Am I on the right track?
Is there a specific function which is called upon a crash in AppDelegate ?
Thanks in advance
EDIT
I've also tried the solution of the following question:
iOS crash log catch, debug info.. Catch and send via email to the Dev team
It actually works but there are some errors that are cause by Swift and not Objective-C (Like Error while unwrapping optional value) were not caught..
Any suggestions?
You should use Crashlytics. You then can use a custom web hook to receive the crash reports.

Resources