npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-intercom-mechazod

v12.3.3

Published

A React Native client for Intercom.io

Downloads

2

Readme

react-native-intercom

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

Installation Guide

  1. Install Intercom for iOS via whichever method you prefer.

    More recently others have had more success Installing Intercom Manually.

    In the past, installing via CocoaPods was recommended.

  2. Install react-native-intercom:

    yarn add react-native-intercom  # or npm install react-native-intercom

    Others have reported issues with the current 11.x version and recommend installing the 10.2.0 version:

    yarn add [email protected]  # or npm install [email protected]
  3. Link native dependencies

    react-native link react-native-intercom
  4. Manually Link the library in Xcode (Linking librarys on iOS)

    1. Open Xcode -> Right click "[Your Project Name]/Libraries" folder and select "Add File to [Your Project Name]" -> Select RNIntercom.xcodeproj located in node_modules/react-native-intercom/iOS.
    2. Open "General Settings" -> "Build Phases" -> "Link Binary with Libraries" and add libRNIntercom.a
  5. Config for iOS (intercom-ios)

    1. Add #import "Intercom/intercom.h" with the other imports at the top of ios/YOUR_PROJECT/AppDelegate.m.

    2. Initialize Intercom in ios/YOUR_PROJECT/AppDelegate.m with your Intercom iOS API Key and your Intercom App ID:

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      
          // Intercom
          [Intercom setApiKey:@"YOUR_IOS_API_KEY_HERE" forAppId:@"YOUR_APP_ID_HERE"];
      
      }
    3. Optional, 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
          [Intercom setDeviceToken:deviceToken];
      
      }
    4. Optional, allow access to photos on iOS. Open Info.plist in Xcode and add a new key "Privacy - Photo Library Usage Description". Or alternately, open ios/YOUR_PROJECT/Info.plist and add:

      <dict>
      
        ...other configuration here...
      
        <key>NSPhotoLibraryUsageDescription</key>
        <string>Send photos to help resolve app issues</string>
      
        ...other configuration here...
      
      </dict>
  6. Config for Android (intercom-android)

    1. 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:

      
      // ...other configuration here...
      
      import com.robinpowered.react.Intercom.IntercomPackage;
      import io.intercom.android.sdk.Intercom;
      
      public class MainApplication extends Application {
      
        @Override
        public void onCreate() {
          super.onCreate();
          Intercom.initialize(this, "YOUR_ANDROID_API_KEY_HERE", "YOUR_APP_ID_HERE");
      
          // ...other configuration here...
      
        }
      
        public List<ReactPackage> getPackages() {
          return Arrays.<ReactPackage>asList(
      
            // ...other configuration here...
      
            new IntercomPackage()
      
            // ...other configuration here...
      
          );
        }
      }
    2. In android/app/src/main/AndroidManifest.xml, add the following code in the respective sections of the file:

      <?xml version="1.0" encoding="utf-8"?>
      <manifest package="com.myapp"
      
        ...other configuration here...
      
      >
        <application
      
          ...other configuration here...
      
          xmlns:tools="http://schemas.android.com/tools"
        >
      
          <!-- ...other configuration here... -->
      
          <service
            android:name="com.robinpowered.react.Intercom.IntercomIntentService"
            android:exported="false">
            <intent-filter
              android:priority="999">
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            </intent-filter>
          </service>
          <receiver
            android:name="io.intercom.android.sdk.push.IntercomPushBroadcastReceiver"
            tools:replace="android:exported"
            android:exported="true" />
        </application>
      </manifest>
    3. In android/build.gradle add maven { url "https://maven.google.com" } (h/t):

      allprojects {
        repositories {
      
          //...other configuration here...
      
          maven { url "https://maven.google.com" }
        }
      }
    4. 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:

      dependencies {
      
        //...other configuration here...
      
        compile 'io.intercom.android:intercom-sdk:5.+'
      }
  7. Import Intercom and use methods

    import Intercom from 'react-native-intercom';
    // or…
    // var Intercom = require('react-native-intercom');
    Intercom.registerIdentifiedUser({ userId: 'Bob' });
    Intercom.logEvent('viewed_screen', { extra: 'metadata' });
    
    //...rest of your file...
    

    Note that calling Intercom.registerIdentifiedUser({ userId: 'Bob' }) (or Intercom.registerUnidentifiedUser()) is required before using methods which require that Intercom know the current user… such as Intercom.displayMessageComposer(), etc.

Usage

Import or Require the module

import Intercom from 'react-native-intercom';

or

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 Unidentified user

Intercom.registerUnidentifiedUser();

Register a Logged In user and post extra metadata

Intercom.registerIdentifiedUser({ userId: 'bob' })
Intercom.updateUser({
    // Pre-defined user attributes
    email: '[email protected]',
    user_id: 'user_id',
    name: 'your name',
    phone: '010-1234-5678',
    language_override: 'language_override',
    signed_up_at: 1004,
    unsubscribed_from_emails: true,
    companies: [{
        company_id: 'your company id',
        name: 'your company name'
    }],
    custom_attributes: {
        my_custom_attribute: 123
    },
});

Set User Hash for Identity Validation (optional)

Intercom.setUserHash(hash_received_from_backend)

IOS (only)

Note: this method is called on the index.ios.js or entry point of your RN app

Intercom.initialize(`<INTERCOM_API_KEY>`, `<INTERCOM_API_KEY>`);

Sign Out

Intercom.logout()

Show Message Composer

Intercom.displayMessageComposer();

Show Message Composer with an Initial Message

Intercom.displayMessageComposerWithInitialMessage('Initial Message');

Set Bottom Padding

Intercom.setBottomPadding(64);

Listen for Unread Conversation Notifications

componentDidMount() {
  Intercom.addEventListener(Intercom.Notifications.UNREAD_COUNT, this._onUnreadChange)
}

componentWillUnmount() {
  Intercom.removeEventListener(Intercom.Notifications.UNREAD_COUNT, this._onUnreadChange);
}

_onUnreadChange = ({ count }) => {
  //...
}

Other Notifications

    // The window was hidden
    Intercom.Notifications.WINDOW_DID_HIDE

Send FCM token directly to Intercom

Firebase.messaging().getToken()
  .then((token) => {
    console.log('Device FCM Token: ', token);
    Intercom.sendTokenToIntercom(token);
});