Does iOS have a 'Notification Listener'?

2019-02-13 22:31发布

问题:

Is it possible to create a Notification Listener in iOS? Something like the NotificationListenerService in Android.

Edit: What I want to do is listen to any notifications coming from any app within the device (missed calls, emails, SMS...)

回答1:

There are two possible answer for this.

NSNotificationCenter is used to post notifications within the app itself. Say for instance you want several classes all to receive information that something has happened (or something) then you would use this. https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/nsnotificationcenter_Class/Reference/Reference.html

If you mean Remote Notifications i.e. push notifications that you receive from Apple then the AppDelegate receives these in a couple of its methods...

https://developer.apple.com/library/ios/documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40006786-CH3-SW16

Edit: It's not possible between apps. See comments.