npm.io
0.0.3 • Published 6 years ago

firebots-react-native

Licence
MIT
Version
0.0.3
Deps
0
Size
98 kB
Vulns
0
Weekly
0

firebots-react-native

PushBots Assignment

Install

$ npm install firebots-react-native --save

Mostly automatic installation

$ react-native link firebots-react-native

Manual installation
Android

In your React Native app:

  1. open android/gradle.properties and add;

    PushBotsAPIKey = "APP_API_KEY"
     PushBotsPlatformCode = "APP_Platform" 
    
  2. Update the following lines in android/build.gradle app module:

    buildToolsVersion = "29.0.2"
    compileSdkVersion = 29
     targetSdkVersion = 29
  3. In android/build.gradle add either jcenter() or mavenCentral()

    allprojects {
      repositories {
          ...
          jcenter() //or mavenCentral()
          ....
      }
     }
  4. This module uses AndroidX should add this lines in android/gradle.properties:

    android.useAndroidX=true
    android.enableJetifier=true

Usage

in your App.js

import React from 'react';

import FireBots from 'react-native-firebots-android';

class App extends React.Component {


  componentWillMount() {
    FireBots.addEventListener('FireBots_onMessageReceived', this.onReceived);
    FireBots.addEventListener('FireBots_onNotificationOpened', this.onClicked);
  }


  componentWillUnMount() {
    FireBots.addEventListener('FireBots_onMessageReceived', this.onReceived);
    FireBots.addEventListener('FireBots_onNotificationOpened', this.onClicked);
  }



  onReceived(notification) {
    console.log(notification)
  }


  onClicked(notification) {
    console.log(notification)

  }


}


export default App;

Keywords