iPhone - detecting crashes, prompting user to send crash log - iphone

Are there any libraries out there that would allow end users to send crash reports to developers?
For example, a user is using my app. It crashes. On boot up, a library loads before everything else and notices there is a crash report and prompts the user to send the crash log to me.
Is this possible? I think the Facebook app does something like this.
Thanks!

You actually have access to crash logs in iTunes Connect. Log in, go to Manage your Applications, pick an app, "View Details", and you should see a "Crash Reports" link to the right of the details pane.
That said, Apple only refreshes these daily, and will only give you access to reports of the most common crashes. If you want finer control, or need the user to submit reports directly, try plcrashreporter. You could ask the user for a submission this way, or just go ahead and automatically send all reports to your server. From the plcrashreporter site:
Introduction
Plausile CrashReporter implements
in-process crash reporting on the
iPhone and Mac OS X. The following
features are supported:
Implemented as an in-process signal
handler. Does not interfer with
debugging in gdb.. Handles both
uncaught Objective-C exceptions and
fatal signals (SIGSEGV, SIGBUS, etc).
Full thread state for all active
threads (backtraces, register dumps)
is provided. If your application
crashes, a crash report will be
written. When the application is next
run, you may check for a pending crash
report, and submit the report to your
own HTTP server, send an e-mail, or
even introspect the report locally.

Another alternative is HopToad - they host the site that will accept the crash reports and notify you.

iOS 5 and later
Tapping Settings > General > About > Diagnostics & Usage will allow you to choose between Automatically Send and Don't Send.
iOS 4 and earlier
By default, opting in is a one-time decision. If you'd like to change your decision, you can reset warnings for your iOS 4 or earlier device so that you will be asked again.
How to reset warnings within iTunes
Connect your iPad, iPhone, or iPod touch to your PC or Mac.
Wait until your device has appeared on the left side of the iTunes window under Devices.
Right-click (Mac or PC) or Control-click (Mac) the icon for your device.
From the shortcut menu, choose Reset Warnings:
The next time you sync after resetting warnings, you should see:
To disagree and stop sending Apple diagnostic and usage information, click No Thanks.
If you don't see the window above
Disconnect your device from your computer.
Open an application on your device.
Press and hold the Sleep/Wake button until the red slider appears, and then press and hold the Home button until the application quits. If you're using iOS 2.x or earlier, press and hold the Home button until the application quits.
Connect your device and sync it with iTunes.
The option to agree or disagree to diagnostics collection should appear again.
Chearz;)

Another alternative that we have been using at my company is Crittercism - http://www.crittercism.com/. They have been very responsive to feature requests and have really helped us prioritize which issues to address.
Their SDK also has the functionality I set out to look for so long ago! :)

Related

iOS is exit(0) deprecated?

Does anyone know if exit(0) is deprecated in iOS application? I know it is not a good decision to manually terminate the app, but does Apple ban the application if we use it in the code?
I got an app which was rejected because of a way of exit (via UIAlertView), doing an exit(5) when user click on the correct button.
I received that:
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.
Please refer to the attached screenshot/s for reference.
The iOS Human Interface Guidelines specify,
"Always Be Prepared to Stop iOS applications stop when people press
the Home button to open a different application or use a device
feature, such as the phone. In particular, people don’t tap an
application close button or select Quit from a menu. To provide a good
stopping experience, an iOS application should:
Save user data as soon as possible and as often as reasonable because an exit or terminate notification can arrive at any time.
Save the current state when stopping, at the finest level of detail possible so that people don’t lose their context when they start the
application again. For example, if your app displays scrolling data,
save the current scroll position."
It would be appropriate to remove any mechanisms for quitting your
app.
A "hidden" exit could be understood as a crash for the user, no?
No, Apple will not reject your app for using exit(0).
You are correct, it is not a great design choice, but it can be useful sometimes.
As Larme mentioned, if used incorrectly, it can be perceived as a crash and a crash will result in your app being rejected.
However, it can be very useful in applicationDidEnterBackground when (on a conditional basis ) you might want to force the app to start a fresh.
No, you must not call exit as your app SHOULD be rejected. This has been repeatedly discouraged by Apple and is known to cause serious bugs with iOS multitask switching. You should simply leave the user to use the home button themselves.
http://developer.apple.com/library/ios/#qa/qa1561/_index.html
"Additionally, data may not be saved, because -applicationWillTerminate: and similar UIApplicationDelegate methods will not be invoked if you call exit. If DURING DEVELOPMENT or TESTING it is necessary to terminate your application, the abort function, or assert macro is recommended."
2012-04-09
Updated to more strongly discourage the exit function, and include best practices for debugging.
2008-08-27
New document that discusses best practices for terminating an iOS application in code.
Straight from the iOS Human Interface Guidelines
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/UEBestPractices/UEBestPractices.html#//apple_ref/doc/uid/TP40006556-CH20-SW27
"Don’t Quit Programmatically
Never quit an iOS app programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your app from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the app malfunction is, you have two choices.
Display an attractive screen that describes the problem and suggests a correction. A screen provides feedback that reassures users that there’s nothing wrong with your app. It puts users in control, letting them decide whether they want to take corrective action and continue using your app or press the Home button and open a different app
If only some of your app's features are unavailable, display either a screen or an alert when people use the feature. Display the alert only when people try to access the feature that isn’t functioning.
If Necessary, Display a License Agreement or Disclaimer
If you provide an end-user license agreement (or EULA) with your iOS app, the App Store displays it so that people can read it before they get your app.
If possible, avoid requiring users to indicate their agreement to your EULA when they first start your app. Without an agreement displayed, users can enjoy your app without delay. However, even though this is the preferred user experience, it might not be feasible in all cases. If you must display a license agreement within your app, do so in a way that harmonizes with your user interface and causes the least inconvenience to users.
If possible, provide a disclaimer within your app description or EULA. Users can then view the disclaimer in the App Store, and you can balance business requirements with user experience needs."

Is it possible to quit iOS app after we do some checks

We don't want the user enter our app if the app is out-dated.
Is that is possible to quit a iOS app when we do some date check BEFORE the app launch?
Or it is possible to quit the application after the main view is loaded?
Before the app launches: no. The launch animation is already in progress when the OS calls main.
After some time (1-2 sec): yes. You can use one of
[[UIApplication sharedApplication] terminateWithSuccess];
exit(0);
abort();
assert(0);
pthread_kill(pthread_self());
so many ways, but neither will go through AppStpre - you're not supposed to close your app programmatically. You're supposed to notify the user via an UIAlertView about the outdated app and disable interaction with the app.
According to Apple you cannot exit(quit) your application through code. i.e if you use exit(0). Your application will be rejected for that. Although you can use exit(1) and delay the exit time of your application. Or you may like to use local notification which is quite handy.
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to
interpret this as a crash. However, if external circumstances prevent
your application from functioning as intended, you need to tell your
users about the situation and explain what they can do about it.
Depending on how severe the application malfunction is, you have two
choices.
Display an attractive screen that describes the problem and suggests a
correction. A screen provides feedback that reassures users that
there’s nothing wrong with your application. It puts users in control,
letting them decide whether they want to take corrective action and
continue using your application or press the Home button and open a
different application
If only some of your application's features are not working, display
either a screen or an alert when people activate the feature. Display
the alert only when people try to access the feature that isn’t
functioning.
Source

Accessing the console data from an iPhone application

When my app crashes, I would like to save the latest console for debug purposes (especially to read system messages such as unrecognized selector)
Is it possible to access the console programatically?
UPDATE:
I've found the answer in the documentations: using STDERR_FILENO.
"Logs an error message to the Apple System Log facility (see man 3 asl). If the STDERR_FILENO file descriptor has been redirected away from the default or is going to a tty, it will also be written there."
It sounds like you want to change the destination for the standard output stream. I've never tried that in iOS, but I'd expect to be able to do that using freopen(). Here's a SO question that may help.
You'll also want to build some debug feature into your app that makes it easy to recover the output. You could post it to a web server, for example, or have the app e-mail it to you.
When your app crashes in a device, a crash log is saved. When you plug your device in, launch XCode, open the "Organizer" window and click on devices. Then look for your device on the left, and click on "crash logs." Together with the information from the .dSYM file that's generated when you build, you can often recover how and where your app crashed. If you really just want to save the information in the console window of XCode when you crash, just click inside the console window, hit Cmd-A (select all), and Cmd-C (copy), then paste into a text editor window.

How to get iPhone crash log from customers?

Does anyone knows how to get crash logs from customers? Instead of manually asking them to sync and go to this directory and this directory and send it.
Is there any automatic way to do send a crash report to our server?
You can perform your own crash-logging with PLCrashReporter. Typically, you write the crash log to a file and then send it to a server the next time the app starts.
In order to prevent an infinite crash-reporting loop (there was one in an early version), you want to do things in a specific order:
Read the file to memory and delete it. (Hopefully this won't crash.)
Parse the crash report and send it to the server. (If it crashes now, the file has been deleted, so it shouldn't happen again.)
Finally, enable crash reporting (so if it crashes in steps 1 or 2, the crash isn't logged).
In any case, you should have a "Oops, it crashed! Do you want to send a crash report?" dialog. I think automatic crash-logging is permitted by the default EULA, but it doesn't hurt to be nice to your users.
If you're worried about losing reports forever if the user says "no", instead of deleting the report, you can do logrotate-style style renaming (i.e. rename report8 to report9, rename report7 to report8, ..., rename report to report0). Then have a "send last N crash reports" button (either set N=10 or count the number of reports), so even if they've accidentally disabled it (or they had no internet at the time), they can still send the report.
iOS 5 and later
Tapping Settings > General > About > Diagnostics & Usage will allow you to choose between Automatically Send and Don't Send.
iOS 4 and earlier
By default, opting in is a one-time decision. If you'd like to change your decision, you can reset warnings for your iOS 4 or earlier device so that you will be asked again.
How to reset warnings within iTunes
Connect your iPad, iPhone, or iPod touch to your PC or Mac.
Wait until your device has appeared on the left side of the iTunes window under Devices.
Right-click (Mac or PC) or Control-click (Mac) the icon for your device.
From the shortcut menu, choose Reset Warnings:
The next time you sync after resetting warnings, you should see:
To disagree and stop sending Apple diagnostic and usage information, click No Thanks.
If you don't see the window above
Disconnect your device from your computer.
Open an application on your device.
Press and hold the Sleep/Wake button until the red slider appears, and then press and hold the Home button until the application quits. If you're using iOS 2.x or earlier, press and hold the Home button until the application quits.
Connect your device and sync it with iTunes.
The option to agree or disagree to diagnostics collection should appear again.
Chearz;)
reference:
http://support.apple.com/kb/HT4305
In iTunes, with their device tethered, if the user control-clicks on the name for their device, they will be able to select "Reset Warnings". Afterwards, a dialog box will pop up when the user next Syncs their device asking if it's OK to send data to Apple. If they click OK, then iTunes will upload all the crash logs from their device to Apple's servers.
Afterwards, you should be able to find your crash logs in iTunes Connect, and download them yourself. New crash logs will appear if your app still has problems and the user Syncs again, all automagically.
If you are talking about normal AppStore sales, Crash Reports are available through iTunes Connect.
Just go to "Manage Your Applications" -> "Your Application" -> And click "View Details" with the version currently active in the AppStore.
You will then get the details of your application, including the crash reports that are send in by your customers.

App Suddenly Closes

Fellow developers. My thanks to you all for your help and suggestions.
My app SafetyKnight has been approved for sale by Apple and I have submitted an inApp Purchase version for approval.
One last 'bug.' When first opening my app, it sometimes quits unexpectedly. Not often. But only rarely sometimes.
Does the MKMap or maybe not strong signal from communications provider cause an app to cut out at start-up?
Any thoughts or suggestions of code I might add to NOT have the app close/crash to enhance the user experience?
Check your app's memory usage during launch and initial view display. The app might be running out of memory if a lot of other Apple processes (or background apps) are running (Mail fetch, music player, etc.). Also make sure you are checking all your error and status return values from your networking code.
From the Organizer, you can access crash reports of any device connected to your computer. Make your application run in debug mode on the device until it crashes and check in debugger where it happens.
Did you handle the low memory notifications in the didReceiveMemoryWarning methods of the relevant UIViewControllers? What is the iOS you are building against?