The ContactAtOnce SDK provides brands with a simple, yet enterprise-grade and secure in-app messaging solution. Through in-app messaging, brands will foster connections with their customers and increase app engagement and retention.
This Quick Start will quickly get you up and running with a project powered by ContactAtOnce. When you’re done, you’ll be able to send messages between an iOS device and ContactAtOnce. To complete this Quick Start, you will need a ContactAtOnce account. You can get the number and login information from the ContactAtOnce account team.
To use the ContactAtOnce In-App Messaging SDK, the following are required:
- XCode 9.1 or later
- Swift 4.0.2 or later, or Objective-C
Note: For information on supported operating systems and devices, refer to ContactAtOnce Mobile SDK System Requirements and Language Guide.
Step 1: Installing the SDK into your project
ContactAtOnce In-App Messaging SDK for iOS supports multiple methods of installations.
Option 1: Using CocoaPods (Recommended)
The SDK is also compatible with CocoaPods, a dependency manager for Swift and Objective-C Cocoa projects. CocoaPods has thousands of libraries and is used in over 2 million apps. It can help you scale your projects elegantly and provides a standard format for managing external libraries.
- Install cocoapods using the following command:
$ gem install cocoapods
- Navigate to your project folder and init new pod using the following command:
$ pod init
- Podfile should be created under your project’s folder. To integrate ContactAtOnce Messaging SDK into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/ContactAtOnceInc/iOSPodSpecs.git' platform :ios, '9.0' use_frameworks! target '<Your Target Name>' do pod 'LPMessagingSDK' end
- Run the following command in the terminal under your project folder:
$ pod install
- In case you wish to upgrade to the latest SDK version and you have already run ‘pod install’, run the following command:
$ pod update
Option 2: Using Libraries Copy to Xcode Project
- Download the latest Messaging SDK from the following link: SDK Repository.
- Once downloaded, extract the ZIP file to a folder on your Mac.
- Copy (Drag and Drop) all framework and bundle files into the project.
- Dependencies will also need to be downloaded and copied into the project. These are TTTAttributedLabel, XMPPFramework, Promises, RNCryptor, and ReachabilitySwift. Any dependencies of these will also need to be addressed.
- In project settings, navigate to the Build Phases tab, and make sure to have ContactAtOnceMessaging.framework under Link Binary With Libraries.
- In project settings, navigate to the Build Phases tab, and click the + button to add a New Run Script Phase. Add the script below in order to loop through the frameworks embedded in the application and remove unused architectures (used for simulator). This step is a workaround for known iOS issue and is necessary for archiving your app before publishing it to the App Store.
Step 2: Configure project settings to connect MessagingSDK
*If using CocoaPods open the Workspace created by CocoaPods rather than your Project and skip steps 1 and 2 below
- In project settings, navigate to the General tab, and add all Framework files to the Embedded Binaries section.
- In the General tab, make sure that the framework files are under Embedded Libraries.
- In Build settings, make sure Always Embed Swift Standard Libraries is set to YES.
- Some XCode Project’s Capabilities need to be switched on in order to support SDK specific features. In XCode, navigate to project’s Targets settings and select the relevant target of your app, then navigate to ‘Capabilities’ tab.
- Push Notifications: SDK uses remote push notification to notify the user whenever a new message from remote user has been received. To use remote push notifications, switch on ‘Push Notifications’ toggle.
Step 3: Initialization
- Inside your class, add the following:
- Instantiate an instance of the Messaging class with MessagingConsumerProperties
- To start a conversation, call Messaging.showConversation with appropriate parameters.
- To show all open conversations, call Messaging.showAllConversations.