initialize method
Future<void>
initialize({
- DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse,
- DidReceiveBackgroundNotificationResponseCallback? onDidReceiveBackgroundNotificationResponse,
override
Initializes the platform-specific alarm implementation.
Must be called once at app startup before any alarm operations. Sets up channels, listeners, and retrieves any pending notification responses.
Implementation
@override
Future<void> initialize({
DidReceiveNotificationResponseCallback? onDidReceiveNotificationResponse,
DidReceiveBackgroundNotificationResponseCallback?
onDidReceiveBackgroundNotificationResponse,
}) async {
_onDidReceiveNotificationResponse = onDidReceiveNotificationResponse;
methodChannel.setMethodCallHandler(_handleMethodCall);
final arguments = <String, Object>{};
_evaluateBackgroundCallback(
onDidReceiveBackgroundNotificationResponse,
arguments,
);
await methodChannel.invokeMethod<void>('initialize', arguments);
final pending = await methodChannel
.invokeMethod<Map<dynamic, dynamic>>('getLastNotificationResponse');
if (pending != null) {
_onDidReceiveNotificationResponse?.call(
NotificationResponse.fromMap(Map<String, dynamic>.from(pending)),
);
}
}