Installation

Install Intercom to see and talk to users of your iOS app. The Intercom for iOS library supports iOS 10+ and requires Xcode 11 to build.

Step 1 - Install Intercom

If you’re new to Intercom, you’ll need to create an account and start your free trial. Then you have three options:

Option 1: CocoaPods

Add Intercom to your Podfile and run pod install

target :YourTargetName do
  pod 'Intercom'
end

Option 2. Carthage

  1. Add github "intercom/intercom-ios" to your Cartfile .
  2. Run carthage update.
  3. Go to your Xcode project's "General" settings. Drag Intercom.framework from Carthage/Build/iOS to the "Embedded Binaries" section.

Option 3: Install Intercom manually

  1. Download Intercom for iOS and extract the zip.
  2. Drag Intercom.framework into your project. Make sure "Copy items if needed" is selected and click Finish.
  1. In the target settings for your app, set the Intercom.framework to “Embed & Sign”. This can be found in the “Frameworks, Libraries, and Embedded Content” section of the “General” tab.
  1. Create a new "Run Script Phase" in your app’s target’s "Build Phases" and paste the following snippet in the script text field:
    bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Intercom.framework/strip-frameworks.sh"
    This step is required to work around an [App Store submission bug[(http://www.openradar.me/radar?id=6409498411401216) when archiving universal binaries.

Step 2 - Update Info.plist

Add a "Privacy - Photo Library Usage Description" entry to your Info.plist as shown below.

This is required by Apple for all apps that access the photo library. It is necessary when installing Intercom due to the image upload functionality. Users will be prompted for the photo library permission only when they tap the image upload button.

Step 3 - Initialize Intercom

First, you'll need to get your Intercom app ID and iOS API key. To find these, just select the 'Intercom for iOS' option in your app settings.

Then initialize Intercom by importing Intercom and adding the following to your application delegate:

@import Intercom;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Intercom setApiKey:@"<Your iOS API Key>" forAppId:@"<Your App ID>"];
}
import Intercom 
  
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
     Intercom.setApiKey("<Your iOS API Key>", forAppId: "<Your App ID>")
}

If your app is using a UISceneDelegate you will need to put your Intercom initialisation code into your SceneDelegate

@import Intercom;

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
	[Intercom setApiKey:@"<Your iOS API Key>" forAppId:@"<Your App ID>"];
}
import Intercom 

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
 	Intercom.setApiKey("<Your iOS API Key>", forAppId: "<Your App ID>")
}

Step 3 - Register your users

You’ll need to register your users with Intercom before you can talk to them or see what they do in your app. If a person visits your mobile app they will be a user - the Intercom SDKs do not create leads or visitors. There are three way to register people who visit your app: (1) register only unidentified users (2) register only identified users (3) register both identified and unidentified users. The option you choose should be informed by the design of your app, namely whether you have a login option.

Register only your unidentified users

If you have an app with no login option (like Angry Birds or a flashlight app), you should register unidentified users only.

Just register an unidentified user in your application's delegate, like so:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Intercom registerUnidentifiedUser];
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
     Intercom.registerUnidentifiedUser()
}

Register only your identified (logged in) users

If people must log in to access your app (as with Facebook, Instagram or Slack) you should follow these instructions to register identified users only.

Best practices for registering users

  • It is important to only register identified users after verification of a login.
  • We recommend giving all your users unique userIds, but if you haven't implemented this, you should call registerUserWithEmail instead of registerUserWithUserId. Don’t use an email address as a userId as this field cannot be changed later. If you choose to registerUserWithEmail, the email address must not be associated with any other users on your workspace.
  1. First, you’ll need to register your user when your app launches, like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    if(loggedIn){
        [Intercom registerUserWithUserId:@"<#123456#>"];
    }
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    if loggedIn {
      Intercom.registerUser(withUserId: "<#123456#>")
    }
}

If you don't have a unique userId to use here, or if you have a userId and an email you can use [Intercom registerUserWithEmail:@"user@exampleapp.com"]; or [Intercom registerUserWithUserId:@"<#123456#>" email:@"user@exampleapp.com"];

  1. You’ll also need to register your user anywhere they log in:
- (void)successfulLogin {
    [Intercom registerUserWithUserId:@"<#123456#>"];
}
func successfulLogin() {
    Intercom.registerUser(withUserId: "<#123456#>")
}

Register both unidentified (non-logged in) and identified (logged in) users

If you have an app with both unidentified and identified users (like Google Maps or YouTube), follow these instructions.

Best practices for registering users

  • It is important to only register identified users after verification of a login.
  • We recommend giving all your users unique userIds, but if you haven't implemented this, you should call registerUserWithEmail instead of registerUserWithUserId. Don’t use an email address as a userId as this field cannot be changed later. If you choose to registerUserWithEmail, the email address must not be associated with any other users on your workspace.

  • First, you’ll need to register your user when your app launches, like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    if(loggedIn){
        [Intercom registerUserWithUserId:@"<#123456#>"];
    } else {
        [Intercom registerUnidentifiedUser];
    }
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    if loggedIn {
        Intercom.registerUser(withUserId: "<#123456#>")
    } else {
        Intercom.registerUnidentifiedUser()
    }
}

If you don't have a unique userId to use here, or if you have a userId and an email you can use [Intercom registerUserWithEmail:@"user@exampleapp.com"]; or [Intercom registerUserWithUserId:@"<#123456#>" email:@"user@intercom.com"];

  1. You’ll also need to register your user anywhere they log in:
- (void)successfulLogin {
    [Intercom registerUserWithUserId:@"<#123456#>"];
}
func successfulLogin() {
     Intercom.registerUser(withUserId: "<#123456#>")
}

How to unregister an identified user

You should only unregister an identified user. Unregistering an unidentified user will result in orphan records that cannot be merged in future.

When users want to log out of your app, simply call:

- (void)logout {
    [Intercom logout];
}
func logout() {
    Intercom.logout()
}

Intercom knows when your app is backgrounded and comes alive again, so you won’t need to re-register your users.

Demo

What next?

  1. Once you've got Intercom installed it's time to configure it for your iOS app.
  2. Enable push notifications so you can send push messages.
  3. Enable Identity Verification for your iOS app.

Installation


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.