Android React Native SDK Setup

These are instructions to include the native Android SDK in your react native app.

Follow the steps mentioned below.

Step 1: Prerequisites

  • Your iZooto App ID. You can find it under Settings in your account.
  • Google/Firebase Server API Key
  • Android Studio
  • An Android 4.3 or newer device or emulator with 'Google Play services' installed.
  • Google-Services.json file should already be added to your project. Learn More.

Step 2: Add iZooto Dependencies

2.1 Open your app/build.gradle (Module: app) file, add/modify the following lines of code inside the Android > defaultConfig section:

android {
 defaultConfig{
    manifestPlaceholders = [
        izooto_app_id : 'YOUR_iZOOTO_APP_ID_HERE'
        ]
    }
}

👍

Sync Gradle

Make sure to press "Sync Now" on the banner that pops up after saving!


Step 3: Add the iZooto SDK

3.1 Navigate to your project directory in a terminal window and run the below command to add the iZooto SDK to your project.

npm install react-native-izooto --save

👍

Verify

Head over to the package.json file and verify that "react-native-izooto": "^1.1.0" has been added.


Step 4: Import and Initialize iZooto

4.1 Add the below code to the App.js file to import iZooto SDK to your project.

import iZooto from 'react-native-izooto';

4.2 Add the below snippet of code to your default class in the App.js file to initialize iZooto.

componentDidMount() {
  iZooto.initialize();
}

Step 5: Run and Test you app

Run your app on a device or the Android emulator to make sure your device is subscribed to notifications and can receive notifications sent from the iZooto dashboard.

❗️

Make sure that you have configured your FCM Server API Key and Sender ID corresponding to you Android Project on iZooto.

Click here for a guide.

Step 6: Customize what your app does when a notification is clicked or received (Optional)

Notification Handlers

onNotificationReceivedListener - This will be called when a notification is received.

onNotificationOpenedListener - This will be called when a notification is tapped on.


Did this page help you?