重复本地通知在react-native-push-notification中不起作用

时间:2019-04-03 13:13:59

标签: react-native react-native-push-notification

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

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 ...??? 
    });
  }

}

我如何每周显示通知。预先感谢。

1 个答案:

答案 0 :(得分:0)

只需传递您选择的日期,就像这样

 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)
   });
}