0

我正在使用反应原生推送通知。

但是当我尝试推送本地日程时,通知不会按预期显示。它总是在我重新加载应用程序时显示(与PushNotification.localNotification相同的行为

如何在PushNotification.localNotificationSchedule中设置参数的日期?我很困惑在那里设定价值。我已经在使用时间戳,但看起来值不同。

1578909865373 => 使用 date.now

1578907260 => 我从字符串日期转换为时间戳

我的代码:

   function toTimestamp(strDate){
    var datum = Date.parse(strDate);
    return datum/1000;
   }

   const dated= toTimestamp('01/13/2020 16:21:00');

    PushNotification.localNotificationSchedule({
        //... You can use all the options from localNotifications
        message: "testing notification", // (required)
        date:  date: new Date(dated)  // in 60 secs
        // date: new Date("2020/01/13")
      });
    }

请帮助如何插入或转换正确的日期值。

谢谢

4

1 回答 1

0

结果我不必除以 1000 时间戳是毫秒。

所以正确的功能是

function toTimestamp(strDate){
var datum = Date.parse(strDate);
return datum;
}
于 2020-01-13T10:50:58.953 回答