Skip to content

talkain/react-native-intercom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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#>"];
}
  1. 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];
}

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 68.0%
  • JavaScript 32.0%