askForNotificationPermission static method

Future<String?> askForNotificationPermission()

This method will ask for permission, enables push notification and send push token to countly server. Should be call after Countly init

Implementation

static Future<String?> askForNotificationPermission() async {
  if (BUILDING_WITH_PUSH_DISABLED) {
    log('askForNotificationPermission, $_pushDisabledMsg', logLevel: LogLevel.ERROR);
    return _pushDisabledMsg;
  }
  if (!_instance._countlyState.isInitialized) {
    String message = '"initWithConfig" must be called before "askForNotificationPermission"';
    log('askForNotificationPermission, $message', logLevel: LogLevel.ERROR);
    return message;
  }
  log('Calling "askForNotificationPermission"');
  final String? result = await _channel.invokeMethod('askForNotificationPermission');

  return result;
}