Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification center - notification not appearing in notification center when they received on active app

I need that all notification will apear in notification center , and in my app only the notification received from background or when app is closed is presented in notification center. Is that my problem ? How to add a notification to notification center from code ?

Thanks!

like image 332
Rivka Schwartz Avatar asked Jul 10 '12 08:07

Rivka Schwartz


2 Answers

Check if application is active when you receive notification

if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive)

If active you can show alert or use Local notification to add message in Notification center. Please note user can remove app from Notification Center as well chose alert not banner from settings.

like image 96
msk Avatar answered Oct 27 '22 04:10

msk


You can use postNotification:, postNotificationName:object: or postNotificationName:object:userInfo: methods to post notification from your code

See NSNotificationCenter reference for more informations

Hope it helps!

like image 33
Martin Pilch Avatar answered Oct 27 '22 03:10

Martin Pilch