react-native-intercom-tween
v0.0.2
Published
A React Native client for Intercom.io
Downloads
4
Readme
react-native-intercom-tween
React Native wrapper for Intercom.io. Based off of intercom-cordova
Install
IOS
npm install react-native-intercom-tween
RNPM
Run rnpm link
CocoaPods
Add the following to your podfile
Pod 'react-native-intercom-tween', :path => '../node_modules/react-native-intercom-tween'
Manual
Follow how to manually link a library here https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content
Android
Run rnpm link
Necessary Code Bits
IOS
More instructions here: Intercom for iOS
Initialize Intercom in your AppDelegate.m
#import "Intercom/intercom.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize Intercom
[Intercom setApiKey:@"<#ios_sdk-...#>" forAppId:@"<#your-app-id#>"];
}
- Intercom's documentation suggests adding the following call in order to receive push notifications for new messages:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[Intercom setDeviceToken:deviceToken];
}
Android
More instructions here: Intercom for Android
Intercom.initialize(getApplicationContext(), "your api key", "your app id");
Usage
Require the module
var Intercom = require('react-native-intercom-tween');
Log an event
Intercom.logEvent('viewed_screen', { extra: 'metadata' });
Register a Logged In user
Intercom.registerIdentifiedUser({ userId: 'bob' });
Register a Logged In user and post extra metadata
Intercom.registerIdentifiedUser({ userId: 'bob' })
.then(() => {
console.log('registerIdentifiedUser done');
return Intercom.updateUser({
email: 'email',
name: 'name',
});
})
.catch((err) => {
console.log('registerIdentifiedUser ERROR', err);
});
Sign Out
Intercom.reset()
Show Message Composer
Intercom.displayMessageComposer();