iOS Critical AlertAlarm notification not working properly with awesome_notifications in Flutter, while working on Android - Stac

I'm trying to implement an alarm-style notification in my Flutter app using awesome_notifications.

I'm trying to implement an alarm-style notification in my Flutter app using awesome_notifications. While it works perfectly on Android (showing an alarm notification that keeps ringing), on iOS it just shows a regular notification.

Here's my notification channel setup:

NotificationChannel(
  channelKey: 'alarm_channel',
  channelName: 'Alarm Notifications',
  channelDescription: 'Notification channel for alarm-style notifications',
  defaultColor: const Color(0xFF023a59),
  ledColor: Colors.red,
  importance: NotificationImportance.Max,
  defaultRingtoneType: DefaultRingtoneType.Alarm,
  playSound: true,
  enableVibration: true,
  vibrationPattern: highVibrationPattern,
  criticalAlerts: true,
  defaultPrivacy: NotificationPrivacy.Public,
)

And here's how I create the notification:

await AwesomeNotifications().createNotification(
  content: NotificationContent(
    id: 2000 + i,
    channelKey: 'alarm_channel',
    title: 'Raccolta Differenziata',
    body: 'Non dimenticare la raccolta differenziata di domani!',
    category: NotificationCategory.Alarm,
    criticalAlert: true,
    wakeUpScreen: true,
    fullScreenIntent: true,
    autoDismissible: false,
  ),
  schedule: NotificationCalendar(
    year: date.year,
    month: date.month,
    day: date.day,
    hour: time.hour,
    minute: time.minute,
    second: 0,
    millisecond: 0,
    preciseAlarm: true,
    allowWhileIdle: true,
  ),
);

I've also:

  1. Added NSCriticalAlertEnabled to Info.plist
  2. Requested critical alert permissions:
await AwesomeNotifications().requestPermissionToSendNotifications(
  permissions: [
    NotificationPermission.Alert,
    NotificationPermission.Sound,
    NotificationPermission.Badge,
    NotificationPermission.Vibration,
    NotificationPermission.CriticalAlert,
  ]
);

My Info.plist configuration:

<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
    <string>remote-notification</string>
</array>
<key>NSCriticalAlertEnabled</key>
<true/>

I've also requested critical alert permissions:

await AwesomeNotifications().requestPermissionToSendNotifications(
  permissions: [
    NotificationPermission.Alert,
    NotificationPermission.Sound,
    NotificationPermission.Badge,
    NotificationPermission.Vibration,
    NotificationPermission.CriticalAlert,
  ]
);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744790553a4593888.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信