Reputation: 133
I need the app gives an alert when it's running in foreground
I test it in my device , when it's in background , the alert shows ; But when app comes in foreground , no alert shows , does this happen by default ?
I've searched some questions , someone says that I can mimic an alert using "UIAlertView"...
Is there any other proper way to do this ?
Upvotes: 2
Views: 2176
Reputation: 3182
@Kjuly is right with the above, but you should also check for UIApplicationStateInactive. It may be easier just to check if
[UIApplication sharedApplication].applicationState != UIApplicationStateActive
Upvotes: 0
Reputation: 16337
When your app is foreground, you have to handle the notification. The system won't pop up an alert for you, you have to catch the notification in application:didReceiveRemoteNotification:
and deal with it yourself.
If you want an alert, then in that method you should summon a UIAlertView
.
Upvotes: 3
Reputation: 35131
I'll do like this:
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
// show an alert view
}
else {
// your local notification configuration
}
Upvotes: 1