6

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!

Rivka Schwartz
  • 524
  • 5
  • 15
  • Does this answer your question? [How to make remote notification appear in notification center when app is in the foreground?](https://stackoverflow.com/questions/67058418/how-to-make-remote-notification-appear-in-notification-center-when-app-is-in-the) – Kacy Apr 14 '21 at 10:40

2 Answers2

1

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!

Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
Martin Pilch
  • 3,245
  • 3
  • 38
  • 61
  • I also want same thing . when my app is open i dont want any alert view .just want showing the notification in notification center .please update if any one have solution . – user100 Apr 11 '14 at 07:41
1

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.

msk
  • 8,885
  • 6
  • 41
  • 72