-
Notifications
You must be signed in to change notification settings - Fork 611
Supporting Firebase push notifications with v3 of the project
bensmiley edited this page Sep 28, 2017
·
1 revision
First download the Firebase push module for v3. Import this module into Android Studio.
Next add the following to your App Manifest:
<service
android:name="co.chatsdk.firebase_extras.MessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service
android:name="co.chatsdk.firebase_extras.InstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
Add a dependency to your build.gradle (Module: app)
file:
compile project(':firebase_extras')
Add the following to your AppObj
onCreate
method:
FirebasePushModule.activate(new FirebasePushHandler.TokenPusher() {
@Override
public void pushToken() {
BNetworkManager.sharedManager().getNetworkAdapter().pushUser();
}
});
Setup Firebase Cloud Messages following this guide.
Finally, open the FirebasePushHandler
class and find the pushToChannel
method. Replace the serverKey
with the value from your Firebase Dashboard -> Project Settings -> Cloud Messaging -> Server Key.
String serverKey = "key=YOURKEY";
Your project is now setup using Firebase for push notifications.