Question

Here's my app scenario: When user swipes a notification I will launch some other app via URL. So it basically launches some other app when notification arrives.

Currently to handle swiping notification scenario, when

- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)

method is invoked, within this method, I call processNotification: method, which contains:

...
[[UIApplication sharedApplication] openURL:url];
...
  • If push received while app is active, url is opened perfectly fine.
  • If push received by swiping or clicking on notification, url is opened in the background but the currently viewed app is my application. For example if my url is tel:123-456-7890, iOS starts the call (you can hear the sound) but active app is not Phone.app, it is my app.

That seemed pretty strange to me. However if I wait for UI to load, and call processNotification: after that, it brings up Phone.app window correctly. (bug in platform? because call happens but my UI is on the top.)

I need a method to delay execution of this processNotification: call, (maybe through an operation queue) until a view controller is loaded. Otherwise, my app stays on top and the URL is opened in the background.

Was it helpful?

Solution

I was facing the same issue, I moved the openURL into main_queue and it seems to be working fine. I did not have to even make that change in didBecomeActive

dispatch_async(dispatch_get_main_queue(), ^(void){
  [[UIApplication sharedApplication] openURL:url];
});

OTHER TIPS

You should delay your handling of the push notification (i.e. calling openURL:) until applicationDidBecomeActive:. Keep the parameters you need from application:didFinishLaunchingWithOptions: but only call your handling code in applicationDidBecomeActive:.

I think the problem here is that SpringBoard is unable to cope with one app transition being called while another is in progress. An iOS bug of course. You should open a bug report at https://bugreport.apple.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top