robinpowered / react-native-intercom

React Native wrapper for Intercom.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-intercom

React Native wrapper for Intercom.io. Based off of intercom-cordova

Install

  1. npm install react-native-intercom
  2. In XCode, in the project navigator right click LibrariesAdd Files to [your project's name]
  3. Go to node_modulesreact-native-intercom➜ iOS and add IntercomWrapper.h and IntercomWrapper.m
  4. Add pod 'Intercom' to your Podfile and run pod install. More instructions here: Intercom for iOS
  5. Initialize Intercom in your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Initialize Intercom
    [Intercom setApiKey:@"<#ios_sdk-...#>" forAppId:@"<#your-app-id#>"];
}

Usage

Require the module

var Intercom = require('react-native-intercom');

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();

About

React Native wrapper for Intercom.io

License:MIT License


Languages

Language:Objective-C 68.7%Language:JavaScript 31.3%