Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android wrong notification time #71

Closed
RobertBrunhage opened this issue Jul 6, 2018 · 11 comments
Closed

Android wrong notification time #71

RobertBrunhage opened this issue Jul 6, 2018 · 11 comments

Comments

@RobertBrunhage
Copy link

So this works correctly on IOS but not on Android. The problem is that when I've used a one-time notification that will fire in, for example, 20h. When the notification pops up it says that notification came 20h ago and not now.

To clarify. I set a notification in 20h. When 20h has gone by and the notification appears it says 20h on the notification (the time when the notification appeared). On IOS, however, it displays it normally so it won't say 20h but more like 1 min etc

@MaikuB
Copy link
Owner

MaikuB commented Jul 6, 2018

So the notification appears at the right time but the OS/notification reports the incorrect time on when the notification occurred?

Also just to confirm its the schedule method you're calling right?

@icavanaugh95
Copy link

I was about to bring this up too. I have the same issue it is when I try to use the schedule method. Even with your example the notification displays the incorrect time but it does occur at the correct time.

@RobertBrunhage
Copy link
Author

RobertBrunhage commented Jul 7, 2018

@MaikuB Yes exactly!

bug

These notifications came up like 1 - 2h ago but show the time when I scheduled them.

@MaikuB
Copy link
Owner

MaikuB commented Jul 7, 2018

Yep was able to repro. Looks like it's due to the fact the notification got built before it got scheduled so I'll have to change the process so that it's only built right before displaying it. It's a relatively easy fix that will only apply for notifications that get scheduled in the next release. This would make it easier to fix issues going forward as not many details of the Notification class can be modified and Google has had history of deprecating fields that they are set via the builder.

For notifications that had already been scheduled I'll add code to modify the Notification object so the correct time information is displayed via this field but I'll eventually do another release to remove that logic.

@RobertBrunhage
Copy link
Author

Sweet, when do you think this will be fixed and pushed?

@MaikuB
Copy link
Owner

MaikuB commented Jul 7, 2018

Should be up now. Looks like my PR automatically closed the issue but I've reopened it, try it out and let me know how it goes

@RobertBrunhage
Copy link
Author

Will the code be used like before or does something need to be added to this:

DateTime scheduledNotificationDateTime =
    new DateTime.now().add(new Duration(seconds: secondsLeft));

    var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
        'your other channel id',
        'your other channel name',
        'your other channel description',
        icon: 'secondary_icon',
        largeIconBitmapSource: BitmapSource.Drawable,
        color: const Color.fromARGB(255, 255, 0, 0));
    var iOSPlatformChannelSpecifics =
    new IOSNotificationDetails();
    var platformChannelSpecifics = new NotificationDetails(
        androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
    await flutterLocalNotificationsPlugin.schedule(
        id,
        title,
        description,
        scheduledNotificationDateTime,
        platformChannelSpecifics);

@MaikuB
Copy link
Owner

MaikuB commented Jul 7, 2018

Code will work as before. It's just what happens behind the scenes that changed

@MaikuB
Copy link
Owner

MaikuB commented Jul 7, 2018

Having said that, I'll eventually be exposing this that controls if that information is displayed. Google is changing the behaviour so displaying that information is opt-in now

@RobertBrunhage
Copy link
Author

yeah, seem like it works for me now, thanks!

@MaikuB MaikuB closed this as completed Jul 10, 2018
@MaikuB
Copy link
Owner

MaikuB commented Jun 1, 2020

Sorry for resurrecting this older thread. I'm finally looking do what I mentioned where I'd remove the kludge put when I mentioned the following

For notifications that had already been scheduled I'll add code to modify the Notification object so the correct time information is displayed via this field but I'll eventually do another release to remove that logic.

I'm looking to do a beta release of the plugin so given how long ago this has been (i.e. before the plugin was more widely used), how hacky it is and how it can lead to making the plugin more difficult to maintain, I wanted to give a heads up on my intentions should anyone have feedback on that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants