As BLiP's integration with Firebase is not working (?) right now, I have found this workaround. Note: all tests were done using a mockup Kotlin app on Android 7.1.1 and 8.0
- Add Firebase and BLiP to the app
// on app level gradle
dependencies{
[...]
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'net.take:blip-chat:2.1.16'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
[...]
}
- Before starting the BLiP Client, get the user's FCM unique token
// This token will be used to send the notification to the specific user
val fcmUserToken = FirebaseInstanceId.getInstance().token
- Add the token to a hashmap to be added on the contact's extras
val extras = HashMap<String, String>()
extras.put("FCMToken", fcmUserToken.toString())
- Create the contact
val authConfig = AuthConfig(AuthType.Dev, "unique_identity", "matching_password")
val account = Account()
account.setFullName("User's Name")
account.setEmail("user_email@domain")
val blipOptions = BlipOptions()
blipOptions.setAuthConfig(authConfig)
blipOptions.setAccount(account)
account.setExtras(extras);
- Open and start BLiP's chat window
// Get the appKey from https://portal.blip.ai/#/application/detail/testdesk/channels/blipchat2.0 @ Setup tab
BlipClient.openBlipThread(baseContext, appKey, blipOptions)
- Whenever you want to send a Push Notification to a specific user:
POST https://fcm.googleapis.com/fcm/send HTTP/1.1
content-type: application/json; charset=UTF-8
Authorization: key=<server_key>
{
"notification": {
"title": "<Notification title>",
"body": "<Notification content>",
"click_action": "<optional_action>",
"icon": "<notification_icon_optional>"
},
"to": "<user_fcm_token>"
}
This request was found here