Show sceen warning when app is in background

I want to show some warnings after a while when the application is in the background.

I am currently using a local notification to display a warning, but I cannot detect an action when the user clicks the cancel local notification button.

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; if (localNotif == nil) return; localNotif.fireDate = [NSDate date]; localNotif.timeZone = [NSTimeZone defaultTimeZone]; // Notification details localNotif.alertBody = @"This is local notification message."; // Set the action button localNotif.alertAction = @"View"; localNotif.alertAction = @"Yes"; localNotif.soundName = UILocalNotificationDefaultSoundName; [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; [localNotif release]; 

Is there any other way to show a warning on the screen when the application is in the background?

+4
source share
2 answers

You cannot determine if the user decided to ignore UILocalNotification . Since you cannot show UIAlertView in the background, your only option is to use UILocalNotification .

But, as you declare, you cannot determine if the user clicked the cancel button, also with iOS6 and the notification center there is no longer a cancel button. Only if the user has chosen to show you notifications as alerts, will there be a close button. However, you cannot find that your notification is closed or not displayed at all.

Your only option is to send spam with a notification until the application is open. But this is considered a bad user interface and can make you hate users.

+1
source

this is not possible in ios.only using a push notification that you can display.

0
source

Source: https://habr.com/ru/post/1498962/


All Articles