init method
Future<bool>
init(
- dynamic backgroundMessageHandler()?, [
- String? notificationChannel = "messages",
- bool loggerEnabled = false,
- bool askPermissions = true,
- bool serverLoggerEnabled = false,
- String? applicationId,
- bool enablePushOnForeground = true,
- String? environment,
override
Implementation
@override
Future<bool> init(Function(Map<dynamic, dynamic>)? backgroundMessageHandler,
[String? notificationChannel = "messages",
bool loggerEnabled = false,
bool askPermissions = true,
bool serverLoggerEnabled = false,
String? applicationId,
bool enablePushOnForeground = true,
String? environment]) async {
methodChannel.setMethodCallHandler(_handle);
print(
"[PushedPlugin][Android][Dart] init loggerEnabled=$loggerEnabled askPermissions=$askPermissions applicationId=$applicationId environment=$environment");
var rawHandle = 0;
if (backgroundMessageHandler != null) {
rawHandle = PluginUtilities.getCallbackHandle(backgroundMessageHandler)
?.toRawHandle() ??
0;
}
final result = await methodChannel.invokeMethod("init", {
"backgroundHandle": rawHandle,
"channel": notificationChannel,
"logger": loggerEnabled,
"askpermissions": askPermissions,
"serverLoggerEnabled": serverLoggerEnabled,
"enablePushOnForeground": enablePushOnForeground,
if (applicationId != null && applicationId.isNotEmpty)
"applicationId": applicationId,
if (environment != null && environment.isNotEmpty) "environment": environment,
});
if (result) {
FlutterPushedMessagingPlatform.status =
ServiceStatus.values[await methodChannel.invokeMethod("getStatus")];
FlutterPushedMessagingPlatform.pushToken =
await methodChannel.invokeMethod("getToken");
print(
"[PushedPlugin][Android][Dart] init success status=${FlutterPushedMessagingPlatform.status} token=${FlutterPushedMessagingPlatform.pushToken}");
}
return result;
}