react-native-intercom
React Native wrapper for Intercom.io. Based off of intercom-cordova.
Installation Guide
-
Add
pod 'Intercom'
toios/Podfile
and then runpod install
in theios
directory to install the cocoapod. -
Open
ios/Podfile
and addpod 'Intercom'
. It will look something like this: -
In the
ios
directory, runpod install
to install the cocoapod. -
Run
npm install react-native-intercom
(oryarn add react-native-intercom
). -
Run
react-native link
to link the package.This will perform some of the linking of
react-native-intercom
. This includes addingpod 'react-native-intercom', :path => '../node_modules/react-native-intercom'
toios/Podfile
. In the future thelink
command can be added to do more of the steps in this installation guide. -
Manually Link the library in Xcode (Linking librarys on iOS)
- Open Xcode -> Right click "[Your Project Name]/Libraries" folder and select "Add File to [Your Project Name]" -> Select
RNIntercom.xcodeproj
located innode_modules/react-native-intercom/iOS
. - Open "General Settings" -> "Build Phases" -> "Link Binary with Libraries" and add
libRNIntercom.a
- Open Xcode -> Right click "[Your Project Name]/Libraries" folder and select "Add File to [Your Project Name]" -> Select
-
Config for iOS (intercom-ios)
-
Add
#import "Intercom/intercom.h"
with the other imports at the top ofios/YOUR_PROJECT/AppDelegate.m
. -
Initialize Intercom in
ios/YOUR_PROJECT/AppDelegate.m
with your Intercom iOS API Key and your Intercom App ID: -
Optional, Intercom's documentation suggests adding the following call in order to receive push notifications for new messages:
-
Optional, allow access to phots on iOS. Open
Info.plist
in Xcode and add a new key "Privacy - Photo Library Usage Description". Or alternately, openios/YOUR_PROJECT/Info.plist
and add:
-
-
Config for Android (intercom-android)
-
In
android/app/src/main/java/com/YOUR_APP/app/MainApplication.java
, add the following code in the respective sections of the file using your Intercom Android API Key and Intercom App ID: -
In
android/app/src/main/AndroidManifest.xml
, add the following code in the respective sections of the file: -
In
android/build.gradle
addmaven { url "https://maven.google.com" }
(h/t): -
Decide which type of push messaging you want to install, and add choosen method to
android/app/build.gradle
. If "Google Cloud Messaging (GCM)", then:
-
-
Import Intercom and use methods
Note that calling
Intercom.registerIdentifiedUser({ userId: 'Bob' })
(orIntercom.registerUnidentifiedUser()
) is required before using methods which require that Intercom know the current user… such asIntercom.displayMessageComposer()
, etc.
Usage
Import or Require the module
or
Log an event
Register a Logged In user
Register Unidentified user
Register a Logged In user and post extra metadata
Set User Hash for Identity Validation (optional)
Sign Out
Show Message Composer
Show Message Composer with an Initial Message
Set Bottom Padding
Listen for Unread Conversation Notifications
Send FCM token directly to Intercom
Firebase.messaging().getToken()
.then((token) => {
console.log('Device FCM Token: ', token);
Intercom.sendTokenToIntercom(token);
});