onNotification static method
Set callback to receive push notifications @param { callback listner } callback returns the error message or an empty string if there is no error
Implementation
static Future<String?> onNotification(Function(String) callback) async {
if (BUILDING_WITH_PUSH_DISABLED) {
log('onNotification, $_pushDisabledMsg', logLevel: LogLevel.ERROR);
return _pushDisabledMsg;
}
log('Calling "onNotification"');
await _channel.invokeMethod('registerForNotification').then((value) {
callback(value.toString());
onNotification(callback);
}).catchError((error) {
callback(error.toString());
});
return '';
}