setAndroidNotification static method

Future setAndroidNotification({
  1. String? channelID,
  2. String? title,
  3. String? message,
  4. String? icon,
  5. String? actionText,
  6. OptLocationCallback? actionCallback,
})

Implementation

static Future<dynamic> setAndroidNotification({
  String? channelID,
  String? title,
  String? message,
  String? icon,
  String? actionText,
  OptLocationCallback? actionCallback,
}) async {
  if (Platform.isAndroid) {
    var callback = 0;
    notificationActionCallback = actionCallback;
    if (actionCallback != null) {
      try {
        callback = PluginUtilities.getCallbackHandle(actionCallback)?.toRawHandle() ?? 0;
      } catch (ex, stack) {
        log('Error getting callback handle', error: ex, stackTrace: stack);
      }
    }

    var data = <String, dynamic>{
      'channelID': channelID,
      'title': title,
      'message': message,
      'icon': icon,
      'actionText': actionText,
      'actionCallback': callback,
    };

    try {
      return await _channel.invokeMethod('set_android_notification', data);
    } catch (ex, stack) {
      log('Error setting notification', error: ex, stackTrace: stack);

      return await const MethodChannel(backgroundChannelID).invokeMethod('set_android_notification', data);
    }

  } else {
    //return Promise.resolve();
  }
}