Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make my iPhone app display a top banner alert, such as the Mail app does?

I have searched for this, and I can't find any documentation about doing these banner / notification / alerts... 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, such that it displayed the notification in the notifications center, but there was no banner alert.

So what are the classes that I use for this?

Thanks!

like image 449
tootsiejasmine Avatar asked Jan 16 '12 06:01

tootsiejasmine


People also ask

How do I get banners on my iPhone?

To see your notifications in Notification Center, do any of the following: On the Lock Screen: Swipe up from the middle of the screen. On other screens: Swipe down from the top center. Then you can scroll up to see older notifications, if there are any.


1 Answers

You can't define what type of alert to be used for your app's notifications. It can be set only by user through Notification Center settings.

Note! Alerts appear only when you app is closed or it is in background. If your app is active (it is in foreground), it will get only a notification (see - (void)applicationDidReceiveMemoryWarning: for details).

like image 77
Aleksejs Mjaliks Avatar answered Oct 23 '22 16:10

Aleksejs Mjaliks