Push Notifications
Integrate your app with Gameball push notifications and interactive in-app messaging.
Gameball uses Firebase to deliver maximum experience in your app. This includes push notifications, interactive in-app messaging.

Configure Gameball With Your Firebase

Before you start, you must configure your Firebase on your Gameball account. Follow the steps in Configure your Firebase account on Gameball for mobile push notifications article from our Help Center related to push notifications.

Handling Push Notifications Integration

For notifications handling, add this code to the onNotification function in your app:
1
onNotification: (notification) => {
2
// you need to check the platform because firebase send the notification based on the platform
3
4
if (Platform.OS === 'android') { // Android
5
if(notification.isGB){
6
// send notification direct to InAppNotification as described below
7
}
8
}
9
else { // IOS
10
if (notification.data.isGB) {
11
// send notification.data to InAppNotification as described below
12
}
13
}
14
}
Copied!
Import InAppNotification
1
import {InAppNotification} from 'react-native-gameball';
Copied!
InAppNotification takes the following properties:
Parameter
Required
Description
Type
isVisible
Required
Whether to show the notification or not
boolean
onCloseFunction
Required
Pass a function that convert isVisible prop from true to false
CallBack Function
notification
Required
Pass the notification data received from the server
Notification
You can use it in different two ways: one is by adding it directly underneath the main app like shown.
1
<Provider>
2
<AppNavigator>
3
<InAppNotification
4
isVisible={this.props.show}
5
notification={this.props.notification}
6
onCloseFunction={this.closeNotification.bind(this)}
7
/>
8
</Provider>
Copied!
Another which is a suggested approach to import it inside a component so that you can use it to pass the props value using redux or state as follows. You had created a new component called NotificationComponent and imported in it the InAppNotification as described above, now in the render function:
1
render(){
2
return(
3
<InAppNotification
4
isVisible={this.props.show}
5
notification={this.props.notification}
6
onCloseFunction={this.closeNotification.bind(this)}
7
/>
8
)
9
}
Copied!
After that, add it underneath your main app component as follows.
1
<Provider>
2
<AppNavigator />
3
<NotificationComponent/>
4
</Provider>
Copied!
Your users can now receive push notifications from Gameball.
Last modified 1mo ago