Skip to content

Instantly share code, notes, and snippets.

@lfmundim
Last active October 20, 2018 17:34
Show Gist options
  • Save lfmundim/0d001e343d284bcd551f5e7ddef58864 to your computer and use it in GitHub Desktop.
Save lfmundim/0d001e343d284bcd551f5e7ddef58864 to your computer and use it in GitHub Desktop.
BLiP Firebase integration workaround

BLiP Firebase Workaround

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

  1. 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'
    [...]
}
  1. 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
  1. Add the token to a hashmap to be added on the contact's extras
val extras = HashMap<String, String>()
extras.put("FCMToken", fcmUserToken.toString())
  1. 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);
  1. 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)
  1. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment