firebots-react-native
v0.0.3
Published
A react-native component for FireBots-Android
Downloads
8
Readme
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:
open
android/gradle.properties
and add;PushBotsAPIKey = "APP_API_KEY" PushBotsPlatformCode = "APP_Platform"
Update the following lines in
android/build.gradle
app module:buildToolsVersion = "29.0.2" compileSdkVersion = 29 targetSdkVersion = 29
In
android/build.gradle
add eitherjcenter()
ormavenCentral()
allprojects { repositories { ... jcenter() //or mavenCentral() .... } }
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;