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.

Resources

Was this article helpful?
YesNo

More from Cloud

How a US bank modernized its mainframe applications with IBM Consulting and Microsoft Azure

9 min read - As organizations strive to stay ahead of the curve in today's fast-paced digital landscape, mainframe application modernization has emerged as a critical component of any digital transformation strategy. In this blog, we'll discuss the example of a fictional US bank which embarked on a journey to modernize its mainframe applications. This strategic project has helped it to transform into a more modern, flexible and agile business. In looking at the ways in which it approached the problem, you’ll gain insights…

Attention new clients: exciting financial incentives for VMware Cloud Foundation on IBM Cloud

4 min read - New client specials: Get up to 50% off when you commit to a 1- or 3-year term contract on new VCF-as-a-Service offerings, plus an additional value of up to USD 200K in credits through 30 June 2025 when you migrate your VMware workloads to IBM Cloud®.1 Low starting prices: On-demand VCF-as-a-Service deployments begin under USD 200 per month.2 The IBM Cloud benefit: See the potential for a 201%3 return on investment (ROI) over 3 years with reduced downtime, cost and…

24 IBM offerings winning TrustRadius 2024 Top Rated Awards

2 min read - TrustRadius is a buyer intelligence platform for business technology. Comprehensive product information, in-depth customer insights and peer conversations enable buyers to make confident decisions. “Earning a Top Rated Award means the vendor has excellent customer satisfaction and proven credibility. It’s based entirely on reviews and customer sentiment,” said Becky Susko, TrustRadius, Marketing Program Manager of Awards. Top Rated Awards have to be earned: Gain 10+ new reviews in the past 12 months Earn a trScore of 7.5 or higher from…

IBM Newsletters

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