Live Assist for 365 and iOS SDK
This document should provide you the details to get you up and running with live assist for iOS (8+). This article is divided into two sections:
1) A Quick Start Guide (sample project)
2) Adding Live Assist to an existing project (Objective-C and Swift)
1) Quick Start
A Quick Start repository is hosted on https://github.com, you can find it here:https://github.com/cafexcomms/liveassist-demo-ios
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 git@github.com/cafexcomms/liveassist-demo-ios.git
Run pod install to install Live Assist:
cd liveassist-demo pod install
Set your account identifier in the liveassist-demo plist file (see here for 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.
Basic setup and configuration is 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.
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','1.0.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/LiveAssist.h>
Create a Configuration
let accountId : Int = 123456; let style = LiveAssistChatStyle.auto; let notifications = true; let mobileSections = ["mobile"]; var assistConfig = AssistConfig.init(accountId: accountId, sections: mobileSections, chatStyle: style, frame: self.view.frame, notifications: notifications);
Create a LiveAssist View
var assistView = LiveAssistView.init(assistConfig: assistConfig);
Add it to your View
self.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 popup for tablets and full screen for mobile devices. This is the recommended setting for projects targeting mobile and tablets.
How do I authorize a chat?
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=@"auth.getAuthenticationToken" 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.
You can find more information about engagement attributes here .
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 applications 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?
Just follow these instructions to obtain 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.