Scheduled notifications

How to create scheduled push notification

Building the apps is not only build it, we need our app can continue to be used by the user continuously. For that we needs a good marketing techniques, and for very long time marketers have been use sms and email marketing to communicate with the users. But today we can add some more option about the techniques to marketing our app using new technologies call Push Notifications. This new technology clearly has more benefits than these older mediums and has been creating waves.

What is Push Notifications

A push notification is a message that pops on a mobile device. App publishers can send that anytime, users don’t have to be in their app to receive them. They can do a lot of thing for example they can show the latest sport score, get a user to take actions, such as downloading a coupon and many more. Here is the reason why push notification is better than sms and email.

  1. One Click Subscribtions
  2. High Click Through Rate
  3. Cross-Platform Dilivery
  4. Compose Message Quickly
  5. Hight User Engagement
  6. And Many more

Building Push Notification

Building Push Notification is never been easy, but there a lot of third party service we can use if we want to implement push notification in out apps. One of the famous is use FCM (Firebase Cloud Messaging). The advantages offered by FCM are :

  1. Send message to any devices
  2. Advanced Message Targeting
  3. Customized Notification Content
  4. No coding required for sending notifications
  5. A/B Test Notifications

Scheduling Notifications

Firebase Cloud Messaging is so easy to setup, implementation and scalability. But in one condition we need to create scheduled notification for out users. For example we have travel app and some of the feature is reminder schedule of the trip, so we need to send push notification to the user when they have schedule for they trip for to day at 07.00 pm. Unfortunately its FCM we can not do that yet we can not create scheduled push notifications to our users.

So the solutions is we can use OneSignal.  OneSignal is basically wrapper of Firebase Push Notifications, but there a lot of feature for doing push notification and one of the feature is Scheduling Push Notifications.


So right now i just wan to give simple example to build scheduled push notification using OneSignal. As in general the push notification need to be able to deliver multi platform. So to do that we need to create a backend app to handle scheduling push notifications. So in this example i will create a backend app using php. But you can also create the backend app using what ever programming language.

So i hope you read the OneSignal documentation to integrate your app with OneSignal project. This is the method that you can use to send scheduled push notifications.

public function sendNotif($userId, $player_id, $message, $send_after)
  $app_id = "YOUR_ONEGINAL_APP_ID";
  $url = "";
  $body = json_encode([
    'app_id' => $app_id,
    'send_after' => $send_after,
    'contents' => [
      'en' => $message
    'data' => [
      'userId' => $userId
    'include_player_ids' => [$player_id]

  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
      "Authorization: Basic YOUR_ONESIGNAL_TOKEN",
      "Content-Type: application/json",

  $response = curl_exec($curl);
  $err = curl_error($curl);

  if ($response) {	
    $res['response'] = json_decode($response);
    return response($res);
    $res["error"] = $err;
    return response($res);


So the field that you should to know is :

  1. app_id => The app project id of your onesignal project.
  2. send_after => The push notification will send after the date for example is 2018-01-09 03:54:00 GMT+7.
  3. content => The message will displayed to user
  4. data => Is additional data that we can send to user.
  5. included_player_ids => For the targeted devices that we can send this push notifications.
  6. You can also send the push notification to all the device and many more read the documentation here.

So basic we just need to doing API Call to OneSignal REST, if you want to create in your android app you can use OneSignal rest api read the documentation here. So i think that for to day see you at next article.

About the author


Hi i'm Rosid, I always learning every day, and the more I learn, the more I realize how much I don’t know.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *