feat: compose Android app and verify native calendar and reminders
This commit is contained in:
@@ -147,18 +147,27 @@ class PluginReminderGateway extends ReminderGateway {
|
||||
final void Function(String key)? onTap;
|
||||
final _plugin = FlutterLocalNotificationsPlugin();
|
||||
Future<void>? _initializing;
|
||||
Future<void> initialize() => _initializing ??= () async {
|
||||
await _plugin.initialize(
|
||||
settings: const InitializationSettings(
|
||||
android: AndroidInitializationSettings('ic_stat_calendar'),
|
||||
),
|
||||
onDidReceiveNotificationResponse: (response) => _select(response.payload),
|
||||
);
|
||||
final launch = await _plugin.getNotificationAppLaunchDetails();
|
||||
if (launch?.didNotificationLaunchApp == true) {
|
||||
_select(launch?.notificationResponse?.payload);
|
||||
Future<void> initialize() => _initializing ??= Future<void>(() async {
|
||||
try {
|
||||
final ready = await _plugin.initialize(
|
||||
settings: const InitializationSettings(
|
||||
android: AndroidInitializationSettings('ic_stat_calendar'),
|
||||
),
|
||||
onDidReceiveNotificationResponse: (response) =>
|
||||
_select(response.payload),
|
||||
);
|
||||
if (ready != true) {
|
||||
throw StateError('通知服务初始化失败');
|
||||
}
|
||||
final launch = await _plugin.getNotificationAppLaunchDetails();
|
||||
if (launch?.didNotificationLaunchApp == true) {
|
||||
_select(launch?.notificationResponse?.payload);
|
||||
}
|
||||
} catch (_) {
|
||||
_initializing = null;
|
||||
rethrow;
|
||||
}
|
||||
}();
|
||||
});
|
||||
void _select(String? payload) {
|
||||
if (payload?.startsWith('hepan:') == true) {
|
||||
onTap?.call(payload!.substring(6));
|
||||
|
||||
Reference in New Issue
Block a user