2021 Call for Code Awards: Live from New York, with SNL’s Colin Jost! Learn more

Create serverless functions to send push notifications


Mobile development can be quite simple. However, when you begin developing the back end, your work can become rather challenging. Building the back end results in additional time in your development cycle, and creating scalability and resiliency provides yet another challenge. To alleviate some of these difficulties, this code pattern explores using a serverless back end for your mobile app.

A serverless approach allows you to run your code or functions based on events. As developers, you won’t need to provision or manage servers. You can spend more time developing your mobile app. The back end can be as simple as pushing your code into the serverless platform.

This code pattern demonstrates using push notifications with a serverless back end. It is easy to create functions that you can schedule to run at specific times. This approach is useful, especially when you want to automatically send push notifications to your users. Automating your notifications to be sent at specific times gives you the ability to really engage your users and send messages at just the right time.

This pattern demonstrates a weather alert application that can notify users of the weather for the next day. It uses IBM Cloud Functions as the back end, the push notification service, and weather data coming from the OpenWeather APIs. The application allows users to select their cities, which types of weather they want to get notified about, and when they want to receive the notifications.

With this code pattern, you can try leveraging mobile push notifications with a serverless approach. See how you might be able to apply it to your own mobile apps.


This application demonstrates how to use IBM Cloud Functions (based on Apache OpenWhisk) as a serverless, mobile back end and as a way to send push notifications to application users. The example use case shows how actions work with the mobile app, and it runs actions that send notifications at a specific time using a cron job configuration.

The serverless functions are used as the mobile application’s back end. The mobile application is a simple weather alert app that pushes notifications for the weather on the next day. The serverless functions uses weather data and processes which data is sent and which subscribers receive the data. An action is invoked from the mobile app to create both a push notification tag and create a cron trigger. The cron trigger is used to schedule the actions and the time of day to run them.

In this code pattern, you learn the following skills:

  1. Create and deploy Cloud Functions.
  2. Trigger Cloud Functions using cron in an alarm trigger.
  3. Use mobile push notifications with Cloud Functions.

The following components and services are used in this code pattern:


serverless functions push notifications flow

  1. The user subscribes to a city, chooses the types of weather to subscribe to, and selects the time to receive the notification.
  2. The mobile app invokes a cloud function sequence through a REST API that creates a push notification tag.
  3. The next action in the sequence is invoked. The action interacts with the Cloud Functions framework to create a cron trigger with the necessary data like location and weather types.
  4. The trigger is fired at the specific time set by the user and invokes a sequence through a configured rule. The action invoked gets data from the OpenWeather APIs.
  5. The next action in the sequence receives the data and builds the message according to what the user requested for a specific weather type.
  6. The next action in the sequence is interfaced with the push notification service, which finally pushes a notification to the user.


Find detailed technical steps for this code pattern in the README.md file in the GitHub repository.

  1. Clone the repo.
  2. Create IBM Cloud Services.
  3. Deploy Cloud Functions.
  4. Configure credentials.
  5. Launch the mobile application.