initializePlatformNotifications method
通知の初期化
Implementation
Future<void> initializePlatformNotifications() async {
try {
// Android用の通知設定を登録
await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(_androidChannel);
// 通知設定の設定
const initializationSettings = InitializationSettings(
android: _initializationSettingsAndroid,
iOS: _initializationSettingsIOS,
);
final isInit = await _flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveNotificationResponse: onDidReceiveNotificationResponse,
);
if (isInit == null || !isInit) {
throw ServiceException(
ServiceErrorType.notificationInitError,
ServiceErrorType.notificationInitError.message,
);
}
} on ServiceException {
rethrow;
} catch (_) {
throw ServiceException(
ServiceErrorType.notificationInitError,
ServiceErrorType.notificationInitError.message,
);
}
}