This document should provide you with the details to get you up and running with live assist for iOS. This article is divided into the following sections:
1) A Quick Start Guide (sample project)
2) Adding Live Assist to an existing project (Objective-C and Swift)
Important:
1. Apple has deprecated UIWebView—this means that from version 1.3.0 the Live Assist for Microsoft Dynamics 365 iOS SDK no longer supports UIWebView. Version 1.2.8 of the SDK does not use UIWebView itself, but it can support applications that do. Apple now rejects an application submission if it includes code related to UIWebView, so from version 1.3.0 the SDK no longer supports applications using UIWebView.
2. Since XCode 13 when app is published on apple store or testFlight the Frameworks version number in plist are changed to the app version which breaks Live Assist and other Frameworks. To avoid this either:
Unselect the option Manage Version and Build Number when you upload the app as per https://stackoverflow.com/questions/69493842
Or set manageAppVersionAndBuildNumber on -exportOptionsPlist for xcodebuild. See https://developer.apple.com/forums/thread/690647
3. The 1.3.5 release of Live Assist 365 iOS SDK (and sample application on Github) includes changes to support directly publishing to Apple Test Flight and as an xc framework to support multiple architectures.
1) Quick Start
A Quick Start repository is hosted on GitHub, see the CafeX Github repository.
This repository contains an iOS project that demonstrates the setup and usage of the Live Assist framework.
The quick start project uses cocoapods as a dependency manager. It contains a PodFile which is configured to download the latest version of the Live Assist Framework.
You can install cocoapods using this gem command.
sudo gem install cocoapods
Running the Sample
Clone this repo:
git clone https://github.com/cafexcomms/liveassist-demo-ios.git
Run pod install to install Live Assist:
cd liveassist-demo-ios pod install
Set your account identifier in the liveassist-demo plist file (See: Finding your Account Id):
plutil -insert AccountId -integer XXXXXXX liveassist-demo/Info.plist
Open the newly-created liveassist-demo.xcworkspace in xCode
Build and Run.
Where is the Live Assist used in the sample?
The sample adds the LiveAssist view to a tabViewController called TabBarViewController.m.
Note: The LiveAssist view should always be added to the topmost Navigation View Controller or TabBar View Controller.
Basic setup and configuration are implemented in this file.
-(void) setupLiveAssist { AssistConfig* assistConfig = [self assistConfig]; assistConfig.mask = [self assistMask]; _assistView = [[LiveAssistView alloc] initWithAssistConfig:assistConfig]; [self.view addSubview:_assistView]; }
Setting Sections
You can set the sections using the setSections method on the live assist view.
Invoking this method will cause the live assist view to reload.
[_assistView setSections:@[@"mobile"]];
2) Adding Live Assist to an existing iOS project
I have my own Objective C project, how do I add and use Live Assist?
Add the live assist dependency to your PodFile
pod 'LiveAssist-xc','~> 1.4.0'
Add the import to your file
#import <LiveAssist/LiveAssist.h>
Create a Configuration
int accountId = 123456; NSArray *mobileSections = @[@"mobile"]; BOOL notifications = YES; AssistConfig* assistConfig = [AssistConfig assistConfigWithAccountId:accountId sections:mobileSections chatStyle:LiveAssistChatStyleAuto frame:self.view.frame notifications:notifications];
Create a LiveAssist View
LiveAssistView *assistView = [[LiveAssistView alloc] initWithAssistConfig:assistConfig];
Add it to your View
[self.view addSubview:assistView];
I have my own Swift project, how do I use Live Assist?
Add the import to your bridging file
import LiveAssist
Create a Configuration
let assistConfig = AssistConfig(accountId: 123456, sections: ["mobile"], chatStyle: .auto, frame: view.frame, notifications: true)
Create a LiveAssist View
let assistView = LiveAssistView(assistConfig: assistConfig)
Add it to your View
view.addSubview(assistView)
3) Further Features
Changing the Style of Window.
Live Assist can run in three types of visual modes.
This setting is passed as a parameter when you create your configuration.
[AssistConfig assistConfigWithAccountId:accountId sections:sections chatStyle:LiveAssistChatStyleAuto notifications:notifications];
LiveAssistChatStyleFullScreen will open the chat window full screen and is the recommended setting if you are targeting mobile devices.
LiveAssistChatStylePopup will open the chat window in a small window and is the recommended setting if you are targeting tablets.
LiveAssistChatStyleAuto will use a popup for tablets and a full screen for mobile devices. This is the recommended setting for projects targeting mobile and tablets.
How do I authorize a chat?
Note: Support for issuer and subscriber parameters will be provided only where pod files will be of version 1.4.0 or higher.
pod 'LiveAssist-xc','~> 1.4.0'
Version 1.4.0 of the iOS Live Assist 365 SDK was updated to provide support for issuer and
subscriber parameters.
As far as the SDK is concerned, these are both strings. The issuer may be hard-coded or
supplied by a REST API, for instance, and a generated user identifier (typically the
Dynamics Contact GUID) would be supplied for the subscriber value.
The SDK provides the following extra properties in AssistConfig* objects that take an
NSString* object:
- issuer
- subscriber
These should be assigned in the usual way that you would assign any property, e.g. with a
previously-instantiated AssistConfig object called assistConfig:
assistConfig.issuer = @"issuer-goes-here";
assistConfig.subscriber = @"subscriber-goes-here";
They should be assigned before the LiveAssistView object is allocated, which of course
takes the AssistConfig object during its initialisation.
A fuller example could be as follows:
NSString* issuer = getIssuer();
NSString* subscriber = getSubscriber();
AssistConfig* assistConfig = [AssistConfig
assistConfigWithAccountId: livePersonAccountId
sections: sections
chatStyle: chatStyle];
assistConfig.issuer = issuer;
assistConfig.subscriber = subscriber;
Note: The above additional implementation should be done in conjunction with the existing
requirements to support authenticated engagements (for Messaging).
Conform to the LiveAssistDelegate protocol.
#import <LiveAssist/LiveAssist.h> @interface TabBarViewController : UITabBarController<LiveAssistDelegate>
Set the authorization name and the delegate on your AssistConfig object before creating your LiveAssistView.
assistConfig.javascriptMethodName=@"authoriseChatWithCallback" assistConfig.delegate=self;
Implement the authoriseChatWithCallback method and pass your JWT token to the callback method.
-(void) authoriseChatWithCallback : (AuthoriseCallback) callback { NSString *authString = @"YOUR JWT STRING GOES HERE -- LEAVE BLANK IF YOU WANT TO REJECT.."; callback(authString); }
How do I set engagement attributes?
You can set engagement attributes using the setEngagementAttributesViaJson method on the live assist view.
See: Engagement Attributes for details.
NSString *shoppingCart = @"{\"numItems\":6,\"type\":\"cart\",\"total\":5.6,\"products\":[{\"product\":{\"price\":0.8,\"name\":\"Cream Cake\",\"category\":\"CAKE\",\"sku\":\"CAKE-1234\"},\"quantity\":2},{\"product\":{\"price\":1,\"name\":\"Ice Bun\",\"category\":\"CAKE\",\"sku\":\"CAKE-2468\"},\"quantity\":4}]}"; [assistView setEngagementAttributesViaJson:shoppingCart];
Allowing Arbitrary Loads for http
It is recommended that you use https links to share files via co-browse.
You will need to configure your application to allow the live assist view to access the internet.
Add these lines to your application's plist.
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <false/> <key>NSIncludesSubdomains</key> <true/> <key>buttonClicked</key> <dict/> </dict> </dict>
Where do I find my account number?
To find your account number, see: Finding your Account Number.
Supporting Foreground Notifications in iOS versions lower than 10.
You can intercept notifications by implementing the didReceiveLocalNotification method in your applications AppDelegate.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification NSLog(@" title = %@ , message = %@",notification.alertTitle,notification.alertBody); }
What is recommended / minimum supported Deployment Target.
The minimum version supported version is 8.
It is recommended that you target the latest version of iOS (10).
What is the size of the Live Assist for Microsoft Dynamics 365 iOS Library?
The iOS library can vary between 400KB and 1MB dependant on Architecture, XCode version, and iOS version.