I am developing an iOS app with swift 3-4 and I have to know the time when my app crashed. How do I achieve that? I don't use firebase.
Integrate crashlytics to know about the crash, line of code that caused the crash, number of times it got crashed for the same issue etc.
You may have these notifications inside UIApplicationDelegate class:
applicationDidFinishLaunchingWithOptions:
applicationWillResignActive:
applicationDidEnterBackground:
applicationWillEnterForeground:
applicationDidBecomeActive:
applicationWillTerminate:
There are also more inside here.
You can do what you want inside the implementation of these delegates, including record time. Note still you don't run short in time, some evwnta give you only limited time to react.
Related
Is there any delegate which fires while app is killed from background in iPhone X?
No. Your app is suspended. It can't get any events because it isn't running. If the app is running in the background, you might get applicationWillTerminate: if the user terminates the app, but I wouldn't count on it. Basically you should assume when the app goes into the background that it might be terminated.
Yes there is please refer to Pushkit framework, I have done that same task using this library, Here]1 is the link all you need to set up, if you want to try in kill mode, you need to do this on Xcode => go to edit scheme in your Xcode.
After setting all this you will be able to do all you need
I'm developing app using push notification, and I had an issue on only iOS10 devices.
I can get currentUserNotificatoinSettings.types during the first launch.
[UIApplication sharedApplication].currentUserNotificationSettings.types;
But after I got pushNotification, the thread, which read currentUserNotificatoinSettings.types, froze without any exceptions.
Somehow I tried to get exceptions by using #try#catch, breakpointNavigator in Xcode, or Zombies on profiler, but it doesn't show any exceptions.
How should I debug this issue? or does anyone know what the cause of this issue is?
You should access UIApplication methods only from on main thread. Wrap your code that accesses the notification settings in a dispatch_async(dispatch_get_main_queue(), ….
I have just solved same problem on iOS 11.2.6. I provide my system callstak when the app is stuck.
In my case, currentUserNotificationSettings called synchronously on main thread, not asynchronously. So that maybe causes deadlock.
I don't know why this is not occurred in iOS 12. But I hope this can help you. Thanks.
So I have a parent app that logs in to a server, creates a user etc. I then use handleWatchKitExtensionRequest from the WatchApp to access the parent app but everything is null.
My question is, does handleWatchKitExtensionRequest get run in a different instance to the parent app? I read somewhere it does but I just need this confirmed.
Thanks
If handleWatchKitExtensionRequest returns nothing it means that the passed reply is never called. This is most probably due to application.didFinishLaunchingWithOptions runs into an error when the app is launched in background mode.
I had a similar issue with my app where I did some initializations on the app's navigationController. It turned out that the navigationController is not accessible when the app is launched in background mode.
I would suggest to completely comment out the code in didFinishLaunchingWithOptions and see if handleWatchKitExtensionRequest calls its reply. If so, uncomment the code in didFinishWithLaunchingWithOptions step by step to detect the faulty code.
This may be really hard to track down because one cannot attach the debugger to the iPhone app at this time of launching.
Another pitfall:
The function signature of handleWatchKitExtensionRequest has changed in Swift 1.2 without giving any compiler errors. It took me hours to figure that out.
I need to know when my app is being terminated (I am not talking about going to background).
Unfortunately the applicationWillTerminate method is never called.
I found some posts on SO about applications going to background, but I really need it when they are terminated. (Pressing home-button twice and then swiping up)
Any ideas how to get notified, when the app is terminated?
When the app is killed you will not get any notification to handle it in your app. The app just gets a signal 9, and the kernel cleans up the process including all threads.
I'm developing iOS-apps for almost two years, and I often have put a breakpoint into the -applicationWillTerminate: method, and the debugger never happened to break there. I think the method is only relevant to apps that are not multitasking-enabled - not multitasking-enabled apps are pretty rare since iOS 5. You'd have to explicitly disable multitasking in your Info.plist file, and there is usually no good reason to do this!
Theres something that is making my app crash between when it gets suspended and when it's reopened. It's a location based app that uses the didUpdateLocations callback/delegate function. I have one or two timers running in the background, and i'm not really sure what happens to them when the app is minimized.
I've been doing some thinking. Really, if the timers aren't running in the background that's fine; they dont need to be. But are they getting suspended, and when the app pulls back up they try to catch up to where they were or something? Why does my app crash when i reopen it?
It's not as simple as crashing when it reopens either. It works if it's a normal amount of time. The app is made to run in the background indefinitely, within reason, so if i wait a day or two before opening it again, it crashes on me. Doesn't crash, necessarily, but freezes. It doesnt send a crash report, just sits there and does nothing. I cant interact with the UI or anything. What could be causing it to do this?
Like i said, the only things that run "indefinitely" are the didUpdateLocations method and one or two timers that check things. That's program flow. It all stems from that. I can offer some code or more information if anybody needs it.
Any ideas?
As mentioned by lehn0058, the timers fire once for each missed increment when the app opens. This is potentially disastrous, and sounds like if the timer isn't set up to count down to something, it should probably be invalidated and restarted each time the app is opened and closed. Another option that i discovered recently is software called Flurry. It's analytical software that i recently integrated into my app. Potentially extremely useful; others should look into it if they havent heard of it.