0

I saw different question regarding this topic like this one: Flutter send local notification when app is closed (alarm) Some of them with accepted answers but nothing seems to work with latest version. Notification package has changed and all of these examples are deprecated.

I tried actual version (flutter_local_notifications: ^12.0.0) and as soon as I close the app I don't receive any notification at all.

const AndroidNotificationChannel channel = AndroidNotificationChannel(
  'high_importance_channel', // id
  'High Importance Notifications', // title
  importance: Importance.high,
);

var detroit = tz.getLocation('America/Detroit');
    var now = tz.TZDateTime.now(detroit);
    await _flutterLocalNotificationsPlugin.zonedSchedule(
      0,
      'scheduled title',
      'scheduled body',
      tz.TZDateTime.now(now.location).add(const Duration(seconds: 5)),
      NotificationDetails(
        android: AndroidNotificationDetails(
          channel.id,
          channel.name,
        ),
      ),
      androidAllowWhileIdle: true,
      uiLocalNotificationDateInterpretation:
          UILocalNotificationDateInterpretation.absoluteTime,
    );

The only notifications that I implemented in the background are the ones coming from firebase cloud functions, but I don't want to rely on this for simple notifications (specially because of the plan).

Is there anything working out there?

Ken White
  • 123,280
  • 14
  • 225
  • 444
Dani
  • 3,128
  • 2
  • 43
  • 91

1 Answers1

0

This was already working. The trick was to not test on debug:

flutter run --release
Dani
  • 3,128
  • 2
  • 43
  • 91