React-native-intercom: Android GCM Integration

Created on 1 Jun 2016  路  20Comments  路  Source: tinycreative/react-native-intercom

I managed to integrate the iphone push notifications but somehow it wasn't so easy for the Android. I guess this is probably since i am a newbee for android and mobile dev.

The app is compiling but no push notification are displayed. I checked the errors from the logcat and found the following error:
intercom-sdk-gcm module not found

I am not sure how to add this module to the gradle file, since just adding it

dependencies {
    compile project(':react-native-intercom')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-vector-icons')
    compile project(':react-native-maps')
    compile project(':react-native-share')
    compile project(':intercom-sdk-gcm') // <-- i add this 
}

throws an error Project with path ':intercom-sdk-gcm' could not be found in project ':app'.

what am i doing wrong? Isn't the react-native-intercom adds the gcm module already?

Most helpful comment

@mrharel I follow the instructions of intercom to configure sdk for GCM. Is there anything else needed to do?

I did all the instructions and still are not getting this working with intercom, I am trying to call Intercom.registerForPush after I registered a identified user on intercom, but this is throwing an error saying that this method does not exists for IntercomWrapper.

All 20 comments

Any news about this?

I managed to solve this.
I manually downloaded the intercom sdk and placed it in the lib folder, like so:

screen shot 2016-06-16 at 10 14 12

and add it to the dependencies in the app gradle:

dependencies {
    compile project(':react-native-intercom')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(':react-native-vector-icons')
    compile project(':react-native-maps')
    compile project(':react-native-share')
    compile(name:'intercom-sdk-gcm-1.1.19', ext:'aar') // <--- add this
}

part of that, just make sure you do all the instructions from the documentation and it should be ok.

@mrharel Yes, that is a requirement. We do not ship with the intercom library intentionally. However many people have been feeling the pain of that so I may consider it.
I've never used the android version of react-native-intercom and don't do much android work so I couldn't have been much help here.

@mrharel I follow the instructions of intercom to configure sdk for GCM. Is there anything else needed to do?

I did all the instructions and still are not getting this working with intercom, I am trying to call Intercom.registerForPush after I registered a identified user on intercom, but this is throwing an error saying that this method does not exists for IntercomWrapper.

I'm getting a similar error: undefined is not a function (evaluating IntercomWrapper.registerForPush(function(error) { ...

Edit: the .aar files can be found here.

I still can't get push notifications working.

  • I added compile ('io.intercom.android:intercom-sdk-gcm:1.+@aar') to my build.graddle
  • Followed all the steps from the intercom documentation

    • Enabled Google services on the Google Developers page

    • Added the GCM API key to intercom

    • Added the Sender ID to strings.xml

  • Tried using IntercomWrapper.registerForPush, but realised it wasn't implemented in react-native-intercom/.../IntercomModule.java.

The ENABLED PUSH MESSAGING field in Intercom is still set to unknown and I can't send push notifications to android users ...

Has anyone managed to get it working ? Did I miss something ?

Same here with yazgazan. Although I can register - unregister user. I haven't been able to enable push notifications. I suspect this has to do with the successfull reception and registration of the device token from GCM to Intercom

I ended up making my own integration for android, using the latest version of the Intercom sdk (3.+). This is less than ideal since we are still using the react-native-intercom package for iOS, which uses the 1.+ version of Intercom. That's not really a solution, nor a particularly beautiful workaround, but that's the easiest solution to implement I could think of.

@yazgazan Thank you for the insight.

@yazgazan Would you like showing us how to achieve the same? Thanks!

It's not really "the same", since I only implemented the featured I needed.

Here is a gist with the java bridge and javascript helpers : https://gist.github.com/yazgazan/f0a96d298bb651dd31aec1cfc056fed1

@yazgazan Thanks a lot! This is a good starting point at least, appreciated.

@browniefed Are there any plans to support Android with Intercom 3+ straight from this package? Thanks!

I am also a little confused, do we need to do everything that "intercom-android" package says OR you have most of its instructions integrated to your package?

I just got GCM pushes working.

The intercom installation docs for Android gives you 3 options:


image


This package is using:

compile ('io.intercom.android:intercom-sdk-base:3.+')

Which corresponds to the Option 3 in the Intercom Docs: the SDK without Push notification support.

To fix this I added this to my android/app/build.gradle:

dependencies {
    compile project(':react-native-intercom') // this was added by react-native link
    compile 'io.intercom.android:intercom-sdk-gcm:3.+' // <= ADD THIS for GCM support
    // ...
}

I hope this helps more people.

Maybe we could add this to the readme?

Does this support intercom 4? I'm getting the same bug with

    compile 'io.intercom.android:intercom-sdk-base:4.+'
    compile 'io.intercom.android:intercom-sdk-fcm:4.+'

@mtkopone you don't need to register for push notifications in android. You only need to send the gcm sender id/firebase token to intercom

and if my senderid is in the strings.xml file and the serverkey in intercom, things should just work?

I think. I've only setup fcm properly see here https://github.com/tinycreative/react-native-intercom/issues/157. I had to do something similar to Step 7 in the gcm setup here https://developers.intercom.com/docs/android-gcm-push-notifications. I'd follow what intercom says (not this repo)

@mtkopone you don't need to register for push notifications in android. You only need to send the gcm sender id/firebase token to intercom

I wish the library did the check internally, and just disregarded the call for Android or made it automatically for iOs

The docs do say it's required for iOs, but _doesn't_ mention that it would effectively kill your Android runtime

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felippepuhle picture felippepuhle  路  9Comments

klamping picture klamping  路  11Comments

lucasharada picture lucasharada  路  9Comments

skleest picture skleest  路  8Comments

AlmogRnD picture AlmogRnD  路  7Comments