react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

Send local notification on interval

Open krapspark opened this issue 10 years ago • 13 comments

Hi,

Is there a way schedule a notification on an interval? For example, notify the user 5PM everyday.

Thank you.

krapspark avatar Sep 01 '16 18:09 krapspark

Have you tried the schedule notification api?

npomfret avatar Sep 14 '16 10:09 npomfret

@npomfret how to configure the schedule notification api once so that it repeats every day? Can you provide an example pls?

Thx

tsvetann avatar Sep 15 '16 10:09 tsvetann

A repeating schedule is supported. However, you can just use PushNotification.localNotificationSchedule to create a single scheduled notification (see the README docs). If you want a repeating notification just create several single notifications, one of each time you want it to fire.

npomfret avatar Sep 15 '16 15:09 npomfret

So if I want to create an indefinite repeating schedule I have to create 99999999 single notification? Wouldn't it be easier to have like {repeat: interval/time} and it just repeats at this interval or time? Or did I get your idea completely wrong?

tsvetann avatar Sep 16 '16 13:09 tsvetann

No, you got the idea right. I'm not sure there's a native API for doing what you want. Unless you can find one for iOS and Android??

If not...

The solution, wherever it goes, is just to schedule multiple notifications. You don't have to schedule all of them at once of course. You can schedule some, and then at a later date schedule some more... just repeat every now and then.

npomfret avatar Sep 16 '16 15:09 npomfret

Repeating notifications are supported using this package in Android. For IOS, there is a PR for it in the react-native repo but it is not merged yet but you can just use that code. I am on travel right now and will put the instructions on how to configure repeating notifications for Android soon.

Sent from my iPhone

On 16-Sep-2016, at 9:27 PM, Nick Pomfret [email protected] wrote:

No, you got the idea right. I'm not sure there's a native API for doing what you want. Unless you can find one for iOS and Android??

If not...

The solution, wherever it goes, is just to schedule multiple notifications. You don't have to schedule all of them at once of course. You can schedule some, and then at a later date schedule some more... just repeat every now and then.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

varun-acintyo avatar Sep 17 '16 04:09 varun-acintyo

@varun-acintyo awesome thanks! Looking forward to an update from you

iSimar avatar Sep 28 '16 12:09 iSimar

Sorry, I am not able to find time to add documentation. You can configure repeating notifications for Android using this package by specifying a repeatType which could be one of "time", "week", "day", "hour", "minute" . If the repeatType is set to time, then there should be one more field repeatTime which should be a number equal to number of milliseconds between each repeating notification. Examples:

PushNotificationAndroid.localNotificationSchedule({
    message: alertBody,
    date: new Date(fireDate),
    repeatType: 'week'
  });

PushNotificationAndroid.localNotificationSchedule({
    message: alertBody,
    date: new Date(fireDate),
    repeatType: 'time',
    repeatTime: 3600000
  });

varungupta85 avatar Sep 29 '16 15:09 varungupta85

Hi Guys! repeatInterval is now supported in PushNotificationsIOS. Can someone please add this here? There already seems to be a PR available for this #288

arhmnsh avatar Nov 22 '16 05:11 arhmnsh

Any update on this guys?

arhmnsh avatar Dec 18 '16 16:12 arhmnsh

@arhmnsh This should be supported automatically if you are using a RN version after the merge.

blaues0cke avatar Oct 30 '17 17:10 blaues0cke

@blaues0cke we should close this issue?

abarisic86 avatar Apr 19 '18 09:04 abarisic86

Close issue, right? We have this working on iOS with simply schedule local notification syntax.

lukewlms avatar Jun 10 '18 21:06 lukewlms