-
Create a Firebase account
-
Go to your Console and create a new project
-
Open your newly created project and click on Grow->Cloud Messaging
-
Click on the Android Logo in the top banner and follow the steps indicated there. They are:
- Write your Android Package Name in the required field. Your package name is generally the
applicationId
in your app-levelbuild.gradle
file - Download the generated
google-services.json
- Add Firebase to your Android project. In Android Studio:
- in the project-level
.gradle
file:
buildscript { dependencies { // Add this line classpath 'com.google.gms:google-services:4.0.1' } }
- in the app-level
.gradle
file:
dependencies { // Add this line implementation 'com.google.firebase:firebase-core:16.0.1' } ... // Add to the bottom of the file apply plugin: 'com.google.gms.google-services'
- resync your gradle
- reinstall your app if needed to make it communicate with Firebase
- Write your Android Package Name in the required field. Your package name is generally the
Once it is communicating, you can test a push notification by using this HTTP Request:
POST https://fcm.googleapis.com/fcm/send HTTP/1.1
content-type: application/json; charset=UTF-8
Authorization: key=<server_key>
Host: fcm.googleapis.com
{
"notification": {
"title": "Firebase",
"body": "Firebase is awesome"
}
}
The server_key
can be found in your Project's Settings->Cloud Messaging->Project Credentials->Server key
- Wherever you choose to open the BLiP Chat window, alongside with other authentication info you are providing, you need to provide the following extra key:
"#inbox.forwardTo":"<firebaseCloudMessagingToken>@firebase.gw.msging.net"
. You can do so with the following code:
// Firebase
val extras = HashMap<String, String>()
val fcmUserToken = FirebaseInstanceId.getInstance().token
extras.put("#inbox.forwardTo", String.format("%s@firebase.gw.msging.net", fcmUserToken))
val identity = "UniqueUserId"
// BLiP
val authConfig = AuthConfig(AuthType.Dev, identity,"pass123PS")
val account = Account()
account.setFullName("TEST SUBJECT")
account.setEmail("email@domain.com")
val blipOptions = BlipOptions()
blipOptions.setAuthConfig(authConfig)
blipOptions.setAccount(account)
account.setExtras(extras);
- You can test single user notifications with the token you get above, by adding a
to
parameter to the previous call:
POST https://fcm.googleapis.com/fcm/send HTTP/1.1
content-type: application/json; charset=UTF-8
Authorization: key=<server_key>
Host: fcm.googleapis.com
{
"notification": {
"title": "Firebase",
"body": "Firebase is awesome"
},
"to": "<fcmUserToken>"
}
After doing the above steps, you need to e-mail integracoes@blip.ai
with the subject "Integração FCM". A BLiP representative will reach you as soon as possible asking for the google-services.json
to manually add the integration with the platform.