initialize method
- DarwinInitializationSettings initializationSettings, {
- DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse,
Initializes the plugin.
Call this method on application before using the plugin further. This should only be done once.
Initialisation may also request notification permissions where users will see a permissions prompt. This may be fine in cases where it's acceptable to do this when the application runs for the first time. However, if your application needs to do this at a later point in time, set the DarwinInitializationSettings.requestAlertPermission, DarwinInitializationSettings.requestBadgePermission and DarwinInitializationSettings.requestSoundPermission values to false. requestPermissions can then be called to request permissions when needed.
The onDidReceiveNotificationResponse
callback is fired when the user
interacts with a notification that was displayed by the plugin and the
application was running. To handle when a notification launched an
application, use getNotificationAppLaunchDetails
.
Implementation
Future<bool?> initialize(
DarwinInitializationSettings initializationSettings, {
DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse,
}) async {
_onDidReceiveNotificationResponse = onDidReceiveNotificationResponse;
_channel.setMethodCallHandler(_handleMethod);
return await _channel.invokeMethod(
'initialize', initializationSettings.toMap());
}