IS2Notifications Class Reference

Inherits from NSObject
Declared in IS2Notifications.h

Overview

IS2Notifications provides access to notifications present on the user’s device. All data returned is pulled from the Notification Centre (NC), and so can persist over reboots.

Setup

+ registerForBulletinNotificationsWithIdentifier:andCallback:

Sets a block to be called whenever a new notification arrives, or an old notification is removed. The identifier must be unique string; it is recommended to use reverse DNS notation, such as “com.foo.bar”.

+ (void)registerForBulletinNotificationsWithIdentifier:(NSString *)identifier andCallback:(void ( ^ ) ( void ))callbackBlock

Parameters

identifier

The identifier associated with your callback

callbackBlock

The block to call once data changes

Declared In

IS2Notifications.h

+ unregisterForNotificationsWithIdentifier:

The inverse of registering for notifications. This must be called when your code is unloaded, else your device will become as unstable as Windows Vista.

+ (void)unregisterForNotificationsWithIdentifier:(NSString *)identifier

Parameters

identifier

The identifier associated with your callback

Declared In

IS2Notifications.h

Data retrieval

+ notificationCountForApplication:

Provides the current count of notifications for the specified application identifier. This will be the number of notifications in the Notification Centre or the application’s badge number, whichever is higher.

+ (int)notificationCountForApplication:(NSString *)bundleIdentifier

Parameters

bundleIdentifier

The bundle identifier of the application specified

Return Value

The count of notifications

Declared In

IS2Notifications.h

+ lockscreenNotificationCountForApplication:

Provides the count of notifications on the lockscreen for the given app. This is calculated by counting how many notifications came in for the specified application whilst the device has been locked. 0 will always be returned whilst the device is unlocked.

+ (int)lockscreenNotificationCountForApplication:(NSString *)bundleIdentifier

Parameters

bundleIdentifier

The bundle identifier of the application specified

Return Value

The count of notifications displayed on the lockscreen.

Declared In

IS2Notifications.h

+ lockScreenIsShowingBulletins

Allows for checking whether the lockscreen is currently displaying any notifications.

+ (bool)lockScreenIsShowingBulletins

Return Value

Whether any lockscreen bulletins are currently being displayed.

Declared In

IS2Notifications.h

+ totalNotificationCountOnLockScreenOnly:

Provides the total count of notifications over all applications.

+ (int)totalNotificationCountOnLockScreenOnly:(BOOL)onLockscreenOnly

Parameters

onLockscreenOnly

If true, this will only return the count of notifications displayed on the lockscreen. If the device is unlocked, this will always be 0.

Return Value

The total count of notifications

Declared In

IS2Notifications.h

+ notificationsForApplication:

Gives an array of BBBulletin objects representing the data currently available in the Notification Centre. If the application specified is prevented from displaying items in the NC through Settings, then this will return an emtpy array.

+ (NSArray *)notificationsForApplication:(NSString *)bundleIdentifier

Parameters

bundleIdentifier

The bundle identifier of the application specified

Return Value

An array of BBBulletin objects.

Declared In

IS2Notifications.h

+ notificationsJSONForApplication:

Gives a JSON representation of data currently available in the Notification Centre. Those using the API via JAvaScript should use this method to obtain a list of notifications. If the application specified is prevented from displaying items in the NC through Settings, then this will return an emtpy array.

+ (NSString *)notificationsJSONForApplication:(NSString *)bundleIdentifier

Parameters

bundleIdentifier

The bundle identifier of the application specified

Return Value

A JSON representation of notifications, in the form:
[
 {
  “title”: “Example notification”,
  “message”: “Example message”,
  “bundleIdentifier”: “com.foo.example”, (Identifier of application for bulletin)
  “timeFired”: 1451528264000 (Timestamp in milliseconds)
 },
 {
  …
 }
]

Declared In

IS2Notifications.h

Functions

+ publishBulletinWithTitle:message:andBundleIdentifier:

Displays a new notification to the user, and will not be stored in the Notification Centre. The default sound for alerts will be used if the device is un-muted, or the default vibration pattern will be used if available. On the lockscreen, this notification will be seen as a new cell in the notification list, or when unlocked, a banner will be shown to the user.

+ (void)publishBulletinWithTitle:(NSString *)title message:(NSString *)message andBundleIdentifier:(NSString *)bundleIdentifier

Parameters

title

The title of the notification

message

A short message to display to the user

bundleIdentifier

A bundle identifier associated with an application on the user’s device. This controls the icon of the notification, and if not set, will default to the identifier for the Settings application.

Declared In

IS2Notifications.h