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 Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

The advantages and disadvantages of private cloud 

6 min read - The popularity of private cloud is growing, primarily driven by the need for greater data security. Across industries like education, retail and government, organizations are choosing private cloud settings to conduct business use cases involving workloads with sensitive information and to comply with data privacy and compliance needs. In a report from Technavio (link resides outside ibm.com), the private cloud services market size is estimated to grow at a CAGR of 26.71% between 2023 and 2028, and it is forecast to increase by…

Optimize observability with IBM Cloud Logs to help improve infrastructure and app performance

5 min read - There is a dilemma facing infrastructure and app performance—as workloads generate an expanding amount of observability data, it puts increased pressure on collection tool abilities to process it all. The resulting data stress becomes expensive to manage and makes it harder to obtain actionable insights from the data itself, making it harder to have fast, effective, and cost-efficient performance management. A recent IDC study found that 57% of large enterprises are either collecting too much or too little observability data.…

IBM Newsletters

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