Support Topics Documentation Slack YouTube Blog

Push notifications repeat not working


(Vidya Sagar) #1

I am working with Backendless api in android for push notifications for my app.
I have configured delivery options as specified in the documentation.
When I run the code, push notification delivered only once.
I intend to deliver it for every one minute.
I am providing my code below.
I couldn’t figure out why my push notifications aren’t repeated
Please provide me with a solution


PublishOptions publishOptions = new PublishOptions();
publishOptions.putHeader( “android-ticker-text”, ticker.getText().toString().trim() );
publishOptions.putHeader( “android-content-title”, title.getText().toString().trim() );
publishOptions.putHeader( “android-content-text”, message.getText().toString().trim() );
DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.setRepeatEvery(60000);
Backendless.Messaging.publish(“admin”, “direct”, publishOptions, deliveryOptions, new AsyncCallback<MessageStatus>() {
@Override
public void handleResponse(MessageStatus messageStatus) {
pd.cancel();
Log.v(“messageSentadmin”,“Sucess”);
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
pd.cancel();
Log.v(“messageSentadmin”,"fail "+backendlessFault.toString());
}
});


(Alexandr Navara) #2

Hello!

Thank you for reporting, there is a mistake in our docs. Interval should be set in seconds instead of milliseconds. So, change this row:

deliveryOptions.setRepeatEvery(60000);

to

deliveryOptions.setRepeatEvery(60);

best regards,
Alex


(Vidya Sagar) #3

Could you give me any insight about how to set date object for expiry with example


(Alexandr Navara) #4

Sure, here you go:

deliveryOptions.setRepeatExpiresAt( new Date( System.currentTimeMillis() + 2 * 60 * 1000 ) );

With this code publishing would be stopped after two minutes.


(Vidya Sagar) #5

Thank you. That was helpfull


(Vidya Sagar) #6

In order to check things, I started a notification chain for every one min without expiry date. How do I stop it?