How do I get the iPhone app to display a top banner warning, such as the Mail app?

I searched for this and I cannot find the documentation about this banner / notification / warning ... but I would really like to implement it. In case my description in words is not clear, here is a picture of what I would like to do:

1 : screen shot

I tried using this code:

UILocalNotification *note = [[UILocalNotification alloc] init]; [note setAlertBody:[NSString stringWithFormat:@"%@ scanned", result]]; [note setAlertAction:@"New Scanned Image"]; [[UIApplication sharedApplication] presentLocalNotificationNow:note]; 

And it worked fine, so it displayed a notification in the notification center, but there was no banner warning.

So what classes do I use for this?

Thanks!

+6
source share
1 answer

You cannot determine what type of alerts will be used for notifications about your application. It can only be set by the user through the settings of the Notification Center.

Attention! Alerts appear only when the application is closed or it is in the background. If your application is active (it is in the foreground), it will receive only a notification (for details, see - (void)applicationDidReceiveMemoryWarning: .

+6
source

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


All Articles