Add and Configure the Live Experience Widget for your iOS App in Objective-C

This topic provides guidelines and an overview for using Objective-C to add and configure the widget in your iOS app.

Before you start

Make sure your development environment is properly set up (see Preparing Your iOS App for the Live Experience Widget). This procedure builds on the concepts and detailed procedure for including and configuring the widget using the Swift programming language. You should read and familiarize yourself with Adding and Configuring the Live Experience Widget for your iOS App before continuing.
Your customers initiate engagements with your associates by tapping on the Oracle Live Experience widget. Add and configure the widget so that it provides the exact experience you intend to deliver to your customers through your iOS app.

In our experience, Xcode is slow to fully initialize the Live Experience framework when working in Objective-C.

Use the following procedure as a reference for educating Xcode into progressively exploring the framework. You should only need to run through this procedure one time. Once Xcode has fully discovered the Live Experience framework in one project, you can add and configure the Live Experience widget in your other projects.

Here's what to do

  1. In Xcode, create a new, simple Objective-C project such as a "Hello-World" project.
  2. In the general settings for your project, under Linked Frameworks and Libraries, include all your frameworks and libraries, and include the Live Experience frameworks.
  3. In your project, import the file OracleLive/OracleLive-Swift.h: #import "OracleLive/OracleLive-Swift.h"
  4. In your Xcode build settings, set Enable Bitcode to No and the project to build on a real device or on a generic iOS device.
  5. Build the project.
  6. In your project, in the viewDidLoad method, enter Cont.
    Xcode should suggest to complete the Controller class for you.
  7. Enter .sha.
    Xcode should suggest attaching the shared property on the class so that it becomes Controller.shared.

Results:

If Xcode is suggesting classes and properties belonging to the Live Experience framework, then you can carry on adding and configuring the Live Experience widget to your other Objective-C projects.

If Xcode does not suggest auto-completing the classes and properties from the Live Experience frameworks, check that you are building the project on a real device or on a generic iOS device, not an iOS simulator. If that doesn't work, try restarting Xcode.

The following sample code shows you how to configure the widget service settings in your Objective-C project:
Controller.shared.service.userID = @"bob@example.com";
Controller.shared.service.tenantID = @"MyTenantID";
Controller.shared.service.clientID = @"clientID";
Controller.shared.service.authToken = @”MyAuthtoken”;
Controller.shared.service.address = @"cloudURL";
The following sample code shows you how to set optional context attributes in your Objective-C project:
[Controller.shared.contextAttributes setValue: @"Bob Dobbs" forKey: @"fullName"];
[Controller.shared.contextAttributes setValue: @"bob@example.com" forKey: @"email"];
[Controller.shared.contextAttributes setValue: @"202-555-0171" forKey: @"phone"];
[Controller.shared.contextAttributes setValue: @"Support Tab" forKey: @"appLocation"];