react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

postLocalNotification - fireDate ignored

Open tststs opened this issue 6 years ago • 47 comments

In React Native 0.61.5 react-native-notifications 3.1.1

On android it doesn't matter what date i pass as fireDate, the notifications is fired immediately.

const someLocalNotification = Notifications.postLocalNotification({
    fireDate: addSeconds(new Date(), 15),
    body: 'Local notificiation!',
    title: 'Local Notification Title',
  });

tststs avatar Feb 06 '20 14:02 tststs

You need to give it an ISO date string. This works for me:

    const payload = {
      body: details.message,
      title: details.title,
      sound: details.soundName,
      userInfo: details.data,
    };
    if (details.fireDate) {
      payload['fireDate'] = details.fireDate.toISOString();
    }
    Notifications.postLocalNotification(payload);

songsterq avatar Feb 11 '20 05:02 songsterq

hey @songsterq

const date = new Date('Apr 30, 2022');
const fireDate = date.toISOString();
  Notifications.postLocalNotification({
    fireDate,
    body: 'Local notificiation!',
    title: 'Local Notification Title',
  }, hash);

It also fires immediately.

tststs avatar Feb 12 '20 15:02 tststs

I am also experiencing this problem

LuisRodriguezLD avatar Feb 19 '20 04:02 LuisRodriguezLD

same here. notification fired immediately android "react-native": "0.61.5", "react-native-notifications": "^3.1.2",

looking at the source code for android, I dont think fireDate is implemented

mfleungac avatar Feb 29 '20 09:02 mfleungac

Same problem. Any workaround?

irondsd avatar Mar 18 '20 13:03 irondsd

+1

wincjh avatar Mar 19 '20 01:03 wincjh

+1 Does it work on iOS?

NagashreeMedaMN avatar Mar 19 '20 08:03 NagashreeMedaMN

@irondsd i manage to implement local scheduled notification using react-native-firebase 5 instead.

https://rnfirebase.io/docs/v5.x.x/notifications/scheduling-notifications

mfleungac avatar Mar 24 '20 04:03 mfleungac

+1 Does it work on iOS?

Didnt test it myself, but seems like it does, only android has this issue

mfleungac avatar Mar 24 '20 04:03 mfleungac

Any fix for this?

JaioSkura avatar Apr 06 '20 08:04 JaioSkura

Same here

sephiroth56 avatar Apr 07 '20 23:04 sephiroth56

Ran into this yesterday. It looks like fireDate isn't even in the payload format, which also caused my Typescript compiler to complain. I'm switching to Promises anyway else I'd fix this.

lib/src/DTO/Notification.ts

pitaman71 avatar May 05 '20 15:05 pitaman71

If we look at the documentation: https://wix.github.io/react-native-notifications/docs/localNotifications

We can see that for postLocalNotification the fireDate attribute is only in the iOS section (small apple icon in the title)

So, I guess, it really isn't implemented for android yet

hannojg avatar May 23 '20 06:05 hannojg

any update?

difaananda40 avatar Jun 03 '20 13:06 difaananda40

Hi! I have done it in a fork, but still have to merge in the oficial repo. Hope to do it this week.

JaioSkura avatar Jun 03 '20 13:06 JaioSkura

glad to hear that!

difaananda40 avatar Jun 03 '20 13:06 difaananda40

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jul 03 '20 13:07 stale[bot]

Hello everyone! Any news on that? I'm not familiar with developing native modules, but I would love to help testing it, as I am currently developing an Android app and I have just found out (the hard way haha) that the lib does not support it yet..

renanliberato avatar Jul 07 '20 16:07 renanliberato

btw I've updated the docs to show that scheduled notifications are not implemented on android yet. The bug being "unclear docs" is fixed. The bigger issue that this feature is not implemented yet, is not fixed though. That makes this issue a feature request instead of a bug report.

douira avatar Jul 07 '20 17:07 douira

Any idea of when this will be implemented?

Fausto95 avatar Jul 27 '20 19:07 Fausto95