ふくしま

ソフトウェアエンジニア

targetSdkVersionをAndroid13(33)にしたらflutter_local_notificationsの通知が出なくなった話

概要

表題の通り

解決策

flutter_local_notificationsのドキュメントに書いていた。

https://pub.dev/packages/flutter_local_notifications#requesting-permissions-on-android-13-or-higher

以下のコードを書いて、パーミッションリクエストの制御をした。

    bool? isAllowed = await _notificationsPlugin
        .resolvePlatformSpecificImplementation<
            AndroidFlutterLocalNotificationsPlugin>()
        ?.requestPermission();
    if (isAllowed == true) {
      logger.i('Notification permission granted');
    } else {
      logger.i('Notification permission not granted');
    }