Skip to main content
Version: 8.9.x

NSNotificationCenter Class

NSNotificationCenter is the primary means through which an application can receive information from the BFG SDK about events. More...

Public Member Functions

void addObserver (@NonNull final Object notificationObserver, @NonNull final String notificationSelector, @NonNull final String notificationName)
 Adds an observer for the specified notification. More...
 
void addObserver (@NonNull final Object notificationObserver, @NonNull final String notificationSelector, @NonNull final String notificationName, @Nullable final Object notificationSender)
 Adds an observer for the specified notification. More...
 
void postNotification (@NonNull final NSNotification notification, final long delay)
 Places the notification in the message queue for handling after the specified delay. More...
 
void removeObserver (@NonNull final Object notificationObserver)
 Removes a previously registered observer for a notification. More...
 
void removeObserver (@NonNull final Object notificationObserver, @NonNull final String notificationName, @Nullable final Object notificationSender)
 Removes an observer from a notification. More...
 

Static Public Member Functions

static NSNotificationCenter defaultCenter ()
 Gets the singleton instance of NSNotificationCenter. More...
 
static void postNotification (@NonNull final String notificationName)
 Dispatch a simple notification where only the notification name is needed. More...
 
static void postNotificationWithParameter (@NonNull final String notificationName, Object parameter)
 Dispatch a simple notification where only the notification name is needed. More...
 

Detailed Description

NSNotificationCenter is the primary means through which an application can receive information from the BFG SDK about events. Please refer to the documentation for individual bfg* classes to find out more about notifications that you can register to observe.IMPORTANT: Observer methods will be invoked on the UI thread. Don't do excessive processing in a notification handler.

Member Function Documentation

◆ addObserver() [1/2]

void com.bigfishgames.bfglib.NSNotificationCenter.addObserver (@NonNull final Object notificationObserver,
@NonNull final String notificationSelector,
@NonNull final String notificationName 
)
inline
Adds an observer for the specified notification. When the notification is received by the NSNotificationCenter, it invokes all selectors registered for the notification.
Parameters
notificationObserverInstance of class observing this event
notificationSelectorName of the method in the observing class that will be invoked when the notification is raised. The instance of the method will be found using reflection
notificationNameName of the notification to listen for

◆ addObserver() [2/2]

void com.bigfishgames.bfglib.NSNotificationCenter.addObserver (@NonNull final Object notificationObserver,
@NonNull final String notificationSelector,
@NonNull final String notificationName,
@Nullable final Object notificationSender 
)
inline
Adds an observer for the specified notification. When the notification is received by the NSNotificationCenter, it invokes all selectors registered for the notification.
Parameters
notificationObserverInstance of class observing this event
notificationSelectorName of the method in the observing class that will be invoked when the notification is raised. The instance of the method will be found using reflection
notificationNameName of the notification to listen for
notificationSenderDeprecated. Provide as NULL

◆ defaultCenter()

static NSNotificationCenter com.bigfishgames.bfglib.NSNotificationCenter.defaultCenter ()
inlinestatic
Gets the singleton instance of NSNotificationCenter. Be sure to initialize the SDK before calling or it will return null.
Returns
the shared default instance of the NSNotificationCenter or null if it has not been initialized.

◆ postNotification() [1/2]

void com.bigfishgames.bfglib.NSNotificationCenter.postNotification (@NonNull final NSNotification notification,
final long delay 
)
inline
Places the notification in the message queue for handling after the specified delay.
Parameters
notificationNotification to be posted.
delayTime interval in seconds.

◆ postNotification() [2/2]

static void com.bigfishgames.bfglib.NSNotificationCenter.postNotification (@NonNull final String notificationName)
inlinestatic
Dispatch a simple notification where only the notification name is needed.
Parameters
notificationNameName of the notification to raise

◆ postNotificationWithParameter()

static void com.bigfishgames.bfglib.NSNotificationCenter.postNotificationWithParameter (@NonNull final String notificationName,
Object parameter 
)
inlinestatic
Dispatch a simple notification where only the notification name is needed.
Parameters
notificationNameName of the notification to raise
parameterParameter to provide with notification

◆ removeObserver() [1/2]

void com.bigfishgames.bfglib.NSNotificationCenter.removeObserver (@NonNull final Object notificationObserver)
inline
Removes a previously registered observer for a notification. If the observer is listening for multiple notifications, all listeners will be removed.
Parameters
notificationObserverInstance of class observing zero or more notifications

◆ removeObserver() [2/2]

void com.bigfishgames.bfglib.NSNotificationCenter.removeObserver (@NonNull final Object notificationObserver,
@NonNull final String notificationName,
@Nullable final Object notificationSender 
)
inline
Removes an observer from a notification.
Parameters
notificationObserverObserver instance registered for notification name
notificationNameName of notification to remove observer from
notificationSenderDeprecated; Provide NULL