0

I have set local notification with flutter_local_notifications 5.0.0 package. All notifications are working fine with the current time zone. But if I travel from India to USA my time zone is changed. And as a result, I do not get any notifications when I am in USA. I set notifications at every 30 minutes from 9 AM to 9 PM. Can anyone help me with this issue?

My code is as below:

  DateTime now = new DateTime.now();
  DateTime dateTime = DateTime(now.year, now.month, now.day, time.hour, time.minute);

  final timeZone = TimeZoneClass();
  // The device's timezone.
  String timeZoneName = await timeZone.getTimeZoneName();
 // Find the 'current location'
  final location = await timeZone.getLocation(timeZoneName);
  final scheduledDate = tz.TZDateTime.from(dateTime, location);

  var iosChannelSpecifics = IOSNotificationDetails();
  var platformChannelSpecifics = NotificationDetails(
      android: androidChannelSpecifics, iOS: iosChannelSpecifics);
  await flutterLocalNotificationsPlugin.zonedSchedule(id, APP_NAME, body, scheduledDate, platformChannelSpecifics,
      matchDateTimeComponents: DateTimeComponents.time,
      payload: payLoad,
      uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime,
      androidAllowWhileIdle: true);
Disha Gajera
  • 208
  • 3
  • 14
  • Have you read this [scheduling-a-notification](https://pub.dev/packages/flutter_local_notifications#scheduling-a-notification)? – Pratik Butani Mar 30 '21 at 12:35
  • Can you share your exact test-cases? I don't think you travelled to the USA for testing notification. – Pratik Butani Mar 30 '21 at 12:37
  • 1
    @PratikButani - I have done the same thing according to doc. But when I travel to another country, all notifications suddenly stopped. I think when I set my notification in India, this method set my current location. And when I reach to another place, this method will not fire because it has already set my previous location. – Disha Gajera Mar 30 '21 at 14:01
  • did you find a solution? @DishaGajera –  Aug 01 '21 at 08:22

0 Answers0