setOnForegroundCallback method
void
setOnForegroundCallback(
- NotificationCallback? callback
Sets the callback for foreground notifications.
This callback will be called when a notification is received while the app is in foreground. This method allows changing the callback after initialization.
Parameters:
callback
: Function that receives a RemoteMessage containing the notification data
Example:
SuperFCM.instance.setOnForegroundCallback((message) {
print('New notification received: ${message.notification?.title}');
});
Implementation
void setOnForegroundCallback(NotificationCallback? callback) {
logger.d('Setting new onForeground callback');
_onForegroundCallback = callback;
}