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

IBM Cloud Virtual Servers and Intel launch new custom cloud sandbox

4 min read - A new sandbox that use IBM Cloud Virtual Servers for VPC invites customers into a nonproduction environment to test the performance of 2nd Gen and 4th Gen Intel® Xeon® processors across various applications. Addressing performance concerns in a test environment Performance testing is crucial to understanding the efficiency of complex applications inside your cloud hosting environment. Yes, even in managed enterprise environments like IBM Cloud®. Although we can deliver the latest hardware and software across global data centers designed for…

10 industries that use distributed computing

6 min read - Distributed computing is a process that uses numerous computing resources in different operating locations to mimic the processes of a single computer. Distributed computing assembles different computers, servers and computer networks to accomplish computing tasks of widely varying sizes and purposes. Distributed computing even works in the cloud. And while it’s true that distributed cloud computing and cloud computing are essentially the same in theory, in practice, they differ in their global reach, with distributed cloud computing able to extend…

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 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 into…

IBM Newsletters

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