OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Time Operators

Use time-based triggers to send push notifications to users based on the time

🚧

Paid Plan Only Feature

"Time Elapsed" operators are only available on the paid plans.
Free plan can still use our Built-In Time Operators

"Time Elapsed" Operators

Available on Paid Plan Only

OneSignal supports the ability to create segments based on how much time has passed since a specific time stamp you specify with the Time Elapsed Greater Than and Time Elapsed Less Than operator.

This allows a much broader range of time-based actions than the first session and last session filters provided automatically as mentioned above.

Using a specific time stamp and the "Time Elapsed" operator can allow you to, for example, set a time that a user last took an action in your app, and then set up an automatic notification to send them a notification after a specified duration has passed.

Step 1: Set a Data Tag for a given player that represents a time (in UTC)

OneSignal.push(function() {
  let timestamp = Math.floor(Date.now() / 1000);
  OneSignal.sendTag("event_key", timestamp).then(function(tagsSent) {
    // Callback called when tags have finished sending
    console.log(tagsSent);
  });
});
long timestamp = Calendar.getInstance().getTime() / 1000;
OneSignal.sendTag("event_key", timestamp);

Step 2: Create a segment using the user tag filter, using the field from step 1 as the KEY, the "Time Elapsed Greater Than" operator, and the desired number of seconds as the VALUE.

Another example, you could send a notification to users who had not confirmed their email address within a week of you sending them a verification email.

By setting a data tag with the intro_email_time key and then using the "Time Elapsed Greater Than" and a value of 604800 (7 days X 24 hours X 60 minutes X 60 seconds).

You could send this as a one-off message, or if you automatically wanted to send an email to even new users who fall into that bucket, could use Automated Messages with this operator to automate on-boarding or engagement actions.

📘

Abandoned Cart Example

If you have a checkout or payment system on your site, Time Operators are perfect for your use case. More details in our Abandoned Cart guide.

Target Device X days before Specific Time

Another helpful feature for Time Operators is the ability to send a notification X time before a certain date.

For example, if you want to send a notification 2 days before a specific date provided by the user.

When the user provides the date you want to track, you can convert that date to a unix timestamp and tag the user.

Then create a segment based on how long before the end date using "time elapsed greater than" and a negative time. 2 days for example would be - 172800 (60 seconds 60 minutes 24 hours * 2 days).

📘

Paid Plan Feature

The "Time Elapsed" operator is included in all paid plans, but is not available on our Free tier.


Built-in Time Operators

Available on Free Plan

You can already set up segment filters using times relative to First Session and Last Session in the segment editor by selecting those filters, as shown below:

Updated about a year ago



Time Operators


Use time-based triggers to send push notifications to users based on the time

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.