1

我正在使用 react-native-push-notification 在我的 react-native 应用程序中显示本地通知。我想每周在上午 10 点重复通知,我编写了以下代码:

import PushNotification from 'react-native-push-notification';
import PushController from './Components/PushController';


export default class App extends Component {
  constructor(props) {
    super(props); 
    this.notify.bind(this);
  }

  notify = () => {
    PushNotification.localNotificationSchedule({
       message: 'You pushed a notification',
       repeatType: 'week',
       date: // what should I write here ...??? 
    });
  }

}

我如何每周显示通知。提前致谢。

4

1 回答 1

1

只需在瞬间传递您选择的日期

 notify = () => {
    PushNotification.localNotificationSchedule({
        message: 'You pushed a notification',
        repeatType: 'week',
        date: new Date(selected date and time)//Thu Feb 27 2020 18:22:00 GMT+0530 (India Standard Time)
   });
}
于 2020-02-27T12:40:17.613 回答