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.
Related
I'm using https://github.com/fechanique/cordova-plugin-fcm plugin and it works great for both platforms.
However, on iOS, the notification permission pop up is invoked right at the launch of the app, and I want it to appear only after the login process is complete.
I have zero knowledge in objective-C so i can't override the classes.
Can anyone please help?
Found a solution in case anyone encounters the same problem in the future...
https://github.com/jjrom/cordova-plugin-fcm/commit/4fedc72b2d94d85a67f6266aef13e774b7a16bfe
When an app is attached to the Xcode debugger, none of the usual lifecycle methods (applicationWillResignActive:, applicationWillTerminate:, etc.) or notifications (UIApplicationWillTerminateNotification, etc) are triggered.
Is there any way for the app to know it's about to be stopped or re-deployed? Perhaps by trapping a signal?
Nope. For all intents and purposes, the STOP button in Xcode immediately terminates the application. There isn't a way to catch this.
applicationWillResignActive and applicationDidEnterBackground and their counterparts do get triggered when you press the home button on the device or simulator (or when you come back). I don't think you can catch the ones related to termination.
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.
I'm writing a WatchKit app which needs to make a query to our Parse server. Because this is a network call, I follow the following procedure:
I make a call from WatchKit to the iOS app using openParentApplication:reply:
Inside of handleWatchKitExtensionRequest:userInfo:reply:, I start a background task with a UIBackgroundTaskIdentifier to ensure the iOS app isn't terminated immediately
I set up my PFQuery and call findObjectsInBackgroundWithBlock:
In the block I pass to the PFQuery, I reply the relevant information to the watch
I wrote this app maybe a month ago before the Apple Watch was out, and it ran just fine in the Watch simulator. Yesterday I received my Apple Watch and I was able to get the app running on the watch, but it doesn't quite work - I managed to figure out that when the iOS app is actively running in the foreground on the iPhone, then everything is great; but if the app is not active (e.g. backgrounded or terminated), then findObjectsInBackgroundWithBlock: never actually calls the block, and execution seems to just stop.
Does anyone have any ideas of what might be going on? My initial thought was that the iOS app is getting suspended/killed before it can complete the query, but I was pretty sure the background task would prevent that.
PS. If anyone stumbles upon this question because they were looking for how to get a WatchKit app running on an actual watch, I found this post extremely helpful in getting it working.
Turned out that I had several problems related to openParentApplication:reply:, and they all seem to have been resolved by using the technique from this post:
http://www.fiveminutewatchkit.com/blog/2015/3/11/one-weird-trick-to-fix-openparentapplicationreply
I had started a background task for my own app, but I didn't use the "bogus workaround" background task described in this post, because it wasn't necessary for me in the simulator. On the watch, though, it apparently was.
I use phone-gap plugin for APN and xcode 5.
https://github.com/phonegap-build/PushPlugin
I put a breakpoint at each function in the plugin.
For some reason when i send a push notification not even single break point are hit.
But the notification received on my device.
Any explanation for this.
Thanks in advance.
There are some things you could check:
Did you set them in in xcode or in the safari debugger? Actually I am not sure if the first option would ever work at all. Have any breakpoints worked in your application?
Is the app running in the foreground when the notification is received? As far as I know, no code is executed on receiving the message if the app is running in the background, so this might also be a reason for not hitting any breakpoints.