Dkri
Dkri

Reputation: 33

iOS, swift, objective C, UserNotificationCenter, NSNotificationCenter

I have an existing project, in which we have built it using NSNotificationCenter. Now if i want to add rich notification to my app, should all the NSNotification calls be replaced by NSUserNotification?

Without replacing when i tried the notification service extension is never getting called for remote as well as local notification.

Upvotes: 2

Views: 549

Answers (1)

Andrea
Andrea

Reputation: 26385

They are totally different. NSNotifications are used as a way to inform objects instances that something has happened in a decoupled way.
This is an implementation of the observer pattern, useful when you need to inform more objects (observers) that an event has happened and they can respond to that event.
NSUserNotifications are used as a way to inform the user that something as happened and is displayed in the NSUser​Notification​Center.

Upvotes: 2

Related Questions