Xamarin iOS SDK Overview
To set up the Xamarin iOS SDK, follow the steps below:
- Gather Required Information
- Add the NuGet Package to your Project
- Create a Config
- Set the User and Add Other Required Code
- Launch Chat
- Customize the UI
1. Gather Required Information
To successfully integrate and test the ASAPP SDK, you will need the following information:
ASAPP repository username & token | Allows you access to download the ASAPP Chat SDK NuGet package. Provided by ASAPP. |
App ID | Also known as the “company marker”, assigned by ASAPP. |
API Hostname | The fully-qualified domain name used by the SDK to communicate with ASAPP’s API. Provided by ASAPP and subject to change based on the stage of implementation. |
Region Code | The ISO 3166-1 alpha-2 code for the region of the implementation. Provided by ASAPP. Default is “US”. |
Client Secret | This can be an empty or random string until otherwise notified by ASAPP. See note below. |
Customer Identifier | A username or similar value used to identify and authenticate the customer. Depending on the stage of implementation, customer identifiers for testing purposes may or may not be provided by ASAPP. |
Authentication Token | A password-equivalent value, which may or may not expire, used to authenticate the customer. |
In the future, the client secret
will be a string, provided by ASAPP, that authorizes the integrated SDK to call the ASAPP API in production. ASAPP recommends that you fetch this string from a server and store it securely using Android KeyStore or iOS Keychain; however, as it is one of many layers of security, you can hard-code the client secret
.
2. Add the NuGet Package to your Project
Before you start, make sure you have a username and token that allow you access to the Xamarin Chat SDK distribution repository - please contact your ASAPP Implementation Manager if you don’t have access yet.
After you have a username and token, select one of the following integration options depending on your needs.
When you add the NuGet package, make sure that you compile your project.
Option 1: Visual Studio
- In the Solutions Explorer, select Tools > Options. The Options window opens.
- In left side menu, expand NuGet Package Manager and select Package Sources.
- In upper right corner, press add + button. It adds a new source in the list set:
- Name: ASAPP ChatSDK
- Source: https://packages.asapp.com/chat/sdk/xamarin/index.json.
- Press the Update button to set the actual name and source to the list item.
- Press OK to close the Options window.
- Right-click on Solution and select Manage NuGet Packages for Solution. The NuGet Package Manager in the VS tab opens.
- Change the source to ASAPP ChatSDK. The Credentials window opens.
- Enter your username and token and press Login. After you login, you will see the ASAPP.SDK NuGet package when you browse the ASAPP NuGet feed.
- Install the NuGet package to your Android and/or iOS projects.
- In Visual Studio, select Preferences > NuGet > Sources. A list of all NuGet sources opens.
- Click the Add button (bottom right). A window for adding the package source opens.
- Enter the following information:
- Name: ASAPP ChatSDK
- Location: https://packages.asapp.com/chat/sdk/xamarin/index.json
- Username: <username>
- Password: <token>
- Select Add Source to add the ASAPP ChatSDK source to Visual Studio NuGet Sources.
- In the main menu, select Project > Manage NuGet Packages. The Manage NuGet Packages window opens.
- In the dropdown menu, select ASAPP ChatSDK and ASAPP.SDK NuGet package and add them to your Android/iOS projects.
Option 2: NuGet.Config file
In the Solution folder, create a new NuGet.Config file, open in a text editor and add:
Save your NuGet.Config and add it to your source control. Then all users will have the ASAPP Xamarin SDK source feed added automatically.
Option 3: Manually download the NuGet package and add it to your project
In your shell, navigate to the Solution folder and add the NuGet source feed with the command:
To download the ASAPP NuGet package to the current folder, run command (The install command does not modify a project file or packages.config).
nuget install ASAPP.SDK
To install the ASAPP.SDK package to your project in Visual Studio, add it as a source under Project→Add NuGet Packages.
3. Create a Config
The ASAPP
class needs to be initialized once with an ASAPPConfig
that defines how the SDK communicates with ASAPP’s API. The client secret can be an empty string for testing purposes; the final value will be provided by ASAPP.
Make sure that your project compiles at this point.
4. Set the User and Add Other Required Code
ASAPP.user
Identify the current user who will be chatting. You may use null as the userIdentifier
to begin an anonymous chat.
Request Context Provider
The requestContextProvider
provides the user’s authentication token (with key ASAPP.AuthTokenKey
, required) and optionally analytics (with key ASAPP.AnalyticsKey) and other data as agreed upon with ASAPP. The SDK calls the requestContextProvider
on a background thread when making a request that relies on user information.
The needsRefresh
flag will be true if the previously cached context is stale and may have expired. If true, be sure to return a fresh authentication token. This operation can be done asynchronously since the function is called on a background thread.
IASAPPDelegate
You must implement the IASAPPDelegate
interface’s methods.
Make sure that your project compiles at this point.
5. Launch Chat
There are four methods for creating a chat view controller. Which method you should call is determined by how you want to display the view controller.
If the chat is being displayed because the user tapped a push notification, the notification’s userInfo
dictionary should be passed in when creating the chat view controller. When a push notification is received, please call ASAPP.CanHandleNotificationWith
to check that the ASAPP SDK can handle the notification’s payload before displaying chat. To create a chat view controller outside the context of a push notification, pass in null
.
Push (Navigation Controller)
Presentation (Modal)
Launch Chat with an Intent
To create a chat view controller that will start a user in a specific state, pass a dictionary describing an initial intent. If there is a business need, ASAPP’s Implementation Manager will provide details.
Push (Navigation Controller)
Presentation (Modal)
Set an Intent with Chat Already Launched
If an ASAPP chat view controller has already been created and displayed, use SetIntent(NSDictionary data)
.
Launch Chat on Simulator
When you develop on the iOS simulator, enable the Keychain entitlement and add a keychain access group for the application’s bundle identifier.
Open the Entitlements.plist
in the iOS project and find the Keychain entitlement and enable it. This automatically adds the application’s identifier as a group. In the project properties under iOS Bundle Signing, set the Custom Entitlements to Entitlements.plist
.
When you deploy to an iOS device, remove the Entitlement as it is not required.
6. Customize the UI
Please see the ASAPP iOS SDK documentation for full details about all customizable styles, such as text or background colors and font sizes.
ASAPP will provide a code snippet to customize the SDK according to a design that has been agreed upon.
Was this page helpful?