zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.74k stars 2.05k forks source link

[SUGGESTION] Need suggestion for creating water reminder app #2042

Open parmarkamlesh opened 3 years ago

parmarkamlesh commented 3 years ago

I want to create water reminder app. my logic is to send notification to user, in between time range of day like Everyday 8AM to 10:30PM at interval of 1.5Hours,

I am thinking to set localNotificationSchedule and set date: new Date(Date.now() + intervalhere), and when user receive notification i want to call another function and then set again new notification with that received notification timestamp+intervalmilisec.

Any suggestion how to do this or it is correct way to do, I want to know how to trigger some code in app WHEN user just receive notification. I want to run that code even user ingnore or intract with notification,

my code:

  PushNotification.localNotificationSchedule({
        channelId: 'oneoone',
        autoCancel: true,
        date: new Date(Date.now() + intervalMs),
        allowWhileIdle: true,
        bigText:
            'Have you drunk water?',
        title: 'Water reminder',
        message: 'Have you drunk water?',
        vibrate: true,
        vibration: 300,
        playSound: true,
        soundName: 'default',
        actions: '["Confirm", "No"]'
    })
Dallas62 commented 3 years ago

Hi @parmarkamlesh This library doesn't aim to trigger custom logic on scheduled notifications. You must set all your notifications before, cancel others notification if the user interact. Regards

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.