react-native-basics-firebase
v0.0.1-alpha.2
Published
Helpers on working with Firebase products
Downloads
3
Maintainers
Readme
react-native-basics-firebase
Helpers on working with Firebase products based on firebase.io
Example of usage
- Create new instance of Messaging class:
/* Messaging.js */
import {Messaging} from 'react-native-basics-firebase';
export const messaging = new Messaging();
- On main app screen add:
/* Home.js */
import {messaging} from "../Messaging";
class Home extends Component {
...
componentDidMount() {
pushNotifications.addListener(this.changeDeviceToken, this.onNotification);
// OR
pushNotifications.addTokenListener(this.changeDeviceToken);
pushNotifications.addNotificationListener(this.onNotification);
}
componentWillUnmount() {
pushNotifications.removeListener(this.changeDeviceToken, this.onNotification);
// OR
pushNotifications.removeTokenListener(this.changeDeviceToken);
pushNotifications.removeNotificationListener(this.onNotification);
}
changeDeviceToken = token => {
...
};
onNotification = (notification, isPressed, originNotification) => {
...
};
...
}
Troubleshooting on installation
- In
MainApplication.java
:
...
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
...
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
...,
new RNFirebasePackage(),
new RNFirebaseNotificationsPackage(),
new RNFirebaseMessagingPackage()
);
}
- Change on
android/build.gradle
if you using old keywords!!!:- from
api
tocompile
; - from
implementation
toprovided
;
example/scripts/react-native-firebase/android/build.gradle
- from