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];
...
url
is opened perfectly fine.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.
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];
});