applicationDidBecomeActive not called when launchi

2019-03-27 04:15发布

问题:

I'm facing this weird problem while trying to implement iOS-8's new Interactive Notifications. When dealing with Local Notifications everything works as expected, but when it comes to APNS - things do not work well.

In details: I get the custom push as it should through the banner (I register only to the minimal context), but when the user taps the button that represents the custom action, my application's delegateapplicationDidBecomeActive: is not called; In fact - the app gets stuck on an inactive mode.

The weird thing is that the app does go to active mode when launched from the Notifications screen (The one to right of the Today). Beside that, on both cases, my delegate:

handleActionWithIdentifier:forRemoteNotification:completionHandler:

does get called with the right Identifier.

Any help would be very much appreciated!

回答1:

Looks like this is an iOS 8 Bug. Found the following on Urban Airship's iOS change log document:

iOS 8 Notes (Updated September 25, 2014)

Known issues with iOS 8.0.0 that may impact your application: - Applications do not enter the 'active' state when started from an interactive notification and subsequent app sessions do not receive the application:didBecomeActive delegate call or
UIApplicationDidBecomeActiveNotification notification. The application state never transitions out of 'inactive' (Radar #18179525). This will impact the accuracy of reporting for applications using interactive notifications.

http://docs.urbanairship.com/reference/libraries/ios/latest/ios_changelog.txt

I Did not find any indication that this had been fixed in the latest iOS 8 versions, including 8.1 and 8.2-Beta, nor any workaround to deal with it.