I'm using remote notifications to wake up my app and conditionally trigger a UILocalNotification.
I've found that if this notification is triggered while the app is not running, all I get is the notification sound (no alert/notification). It works as expected if the app is in the background.
Registering for remote notifications in AppDelegate:
let settings = UIUserNotificationSettings(forTypes: (.Badge | .Sound | .Alert), categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
Creating/Firing of UILocalNotification (as a result of didReceiveRemoteNotification
)
var notification = UILocalNotification()
notification.alertTitle = "My App"
notification.alertBody = "Hello World!"
notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.sharedApplication().presentLocalNotificationNow(notification)
As far as I can tell from the documentation, notification behavior when the app is in the background and simply not running should be the same..
When the system delivers a local notification, several things can happen, depending on the app state and the type of notification. If the app is not frontmost and visible, the system displays the alert message, badges the app, and plays a sound—whatever is specified in the notification. If the notification is an alert and the user taps the action button (or, if the device is locked, drags open the action slider), the app is woken up or launched.
Source: UILocalNotification Documentation
Insight into what's going on here is much appreciated!