March 1, 2019 By Josephine Justin
Anantha Krishnan K G
3 min read

Integrate IBM Cloud Push Notifications Service with a React Native app using React Native SDKs

React Native is an open source framework for easy cross-platform, which helps in building the apps using Javascript. This blog post describes the steps to be followed to integrate IBM Cloud Push Notifications Service with a React Native app using its React Native SDKs (available here).

About the app

This blog helps you build a React Native app that shows all the repositories of a GitHub Organization. It also sends a push notification when an issue or a pull request is created/updated/closed. IBM Cloud Functions actions trigger the push notifications. The complete app is available here.

Push Notifications Service

Create and configure a Push Notifications Service instance from the IBM Cloud catalog. You can refer to this tutorial to create and configure the instance.

IBM Cloud Functions

IBM Cloud Functions are used to create GitHub actions and triggers. Please refer to the IBM Cloud Functions doc for details.

Create an action to get all repositories

Refer to getReposAction.js to create a Node.js action. Create the action using IBM Cloud Functions.

let orgName = "Gypsyan"; defines the organization of the GitHub. Modify this to be the same name as your GitHub org.

This action retrieves all the repositories of the GitHub org and returns the details of the repositories:

Create an action to listen for Github web-hooks

Create a Node.js action with the code given in ReactNativeAction.js. Make sure to update the apikeyappId, and apiHost. Update the values of these attributes as per the Push Notifications Service instance created in the first step. This action uses the openwhisk package, which is a wrapper around the Apache OpenWhisk APIs.

This action tracks the GitHub activity. Based on the activity, a push notification payload is created that triggers a notification.

Create a Cloud Functions trigger

Create a trigger and add the ReactNativeAction in the actions field.

Add the GitHub webhook

Open the GitHub repository settings and add a webhook with IBM Cloud Functions trigger. Select Issues and Pull Request.

GitHub will invoke the IBM Cloud Functions trigger once any issues or pull request event happens in the GitHub org repositories.

Configure the client app

Go to the  App.js and add push credentials and Cloud Functions credentials.

Configure the client app—iOS and Android—using the bmd-push-react-native SDK documentation.

Run the app

Run your app using react-native run-ios or react-native run-android commands.

Register the device for Push Notifications

Click on the bell icon to register the device for push notifications.

Trigger notifications

To test the app, create an issue or pull request in any repository of your GitHub organization.


Was this article helpful?

More from Cloud

The history of the central processing unit (CPU)

10 min read - The central processing unit (CPU) is the computer’s brain. It handles the assignment and processing of tasks, in addition to functions that make a computer run. There’s no way to overstate the importance of the CPU to computing. Virtually all computer systems contain, at the least, some type of basic CPU. Regardless of whether they’re used in personal computers (PCs), laptops, tablets, smartphones or even in supercomputers whose output is so strong it must be measured in floating-point operations per…

A clear path to value: Overcome challenges on your FinOps journey 

3 min read - In recent years, cloud adoption services have accelerated, with companies increasingly moving from traditional on-premises hosting to public cloud solutions. However, the rise of hybrid and multi-cloud patterns has led to challenges in optimizing value and controlling cloud expenditure, resulting in a shift from capital to operational expenses.   According to a Gartner report, cloud operational expenses are expected to surpass traditional IT spending, reflecting the ongoing transformation in expenditure patterns by 2025. FinOps is an evolving cloud financial management discipline…

IBM Power8 end of service: What are my options?

3 min read - IBM Power8® generation of IBM Power Systems was introduced ten years ago and it is now time to retire that generation. The end-of-service (EoS) support for the entire IBM Power8 server line is scheduled for this year, commencing in March 2024 and concluding in October 2024. EoS dates vary by model: 31 March 2024: maintenance expires for Power Systems S812LC, S822, S822L, 822LC, 824 and 824L. 31 May 2024: maintenance expires for Power Systems S812L, S814 and 822LC. 31 October…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters