Skip to content

Commit db4a52c

Browse files
committed
4.7.2
1 parent 2b33bac commit db4a52c

File tree

2 files changed

+90
-9
lines changed

2 files changed

+90
-9
lines changed

InContextSDK.framework.zip

858 KB
Binary file not shown.

README.md

+90-9
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,103 @@
22

33
## Installation
44

5+
Download InContextSDK.framework.zip, extract it and add InContextSDK.framework to your project. It should appear listed under *General > Linked Frameworks and Libraries* and *General > Embedded Binaries*.
56

6-
### Start a task
7+
For objective-c projects, also set *Build Settings > Always Embed Swift Standard Libraries* to `Yes`
8+
9+
Finally, frameworks should be added to the path already, in case they're not add `@executable_path/Frameworks` to *Build Settings > Runpath Search Paths*.
10+
11+
## Usage
12+
13+
Starting a task and and retrieving its results works similarly for both for swift and objective-c.
14+
- A task is started by instantiating the `TaskViewController` from the `TaskStoryboard` and showing it.
15+
- ProjectID, SubjectGroupID and UserHash are set using the `data` property of the task controller.
16+
- Finally, to receive the task end event and success, we can use the `delegate` property of the task controller. The listener needs to implement the `TaskDelegate` protocol. In the examples, we've used the main ViewController for that purpose.
17+
18+
#### Swift
719

820
```swift
9-
let storyboard = UIStoryboard(name: "Task", bundle: Bundle(identifier: "com.eyesquare.InContextSDK"))
10-
let controller = storyboard.instantiateViewController(withIdentifier: "TaskViewController") as! TaskViewController
21+
import UIKit
22+
import InContextSDK
23+
24+
25+
class ViewController: UIViewController, TaskDelegate {
26+
27+
...
1128

12-
controller.delegate = self
13-
controller.data = TaskData(ProjectID: "fallback-demo", SubjectGroupID: "fb", UserHash: "carlos")
29+
//---------------------------------------------------------------------------
30+
@IBAction func onButtonPressed(_ sender: UIButton) {
1431

15-
self.present(controller, animated: false, completion: nil)
32+
// instantiate the controller
33+
let storyboard = UIStoryboard(name: "Task", bundle: Bundle(identifier: "com.eyesquare.InContextSDK"))
34+
let controller = storyboard.instantiateViewController(withIdentifier: "TaskViewController") as! TaskViewController
35+
36+
// define task variables
37+
let taskData = TaskData(ProjectID: "2017-05_DE030_j2vyo5nj", SubjectGroupID: "fbpers", UserHash: "1234")
38+
39+
// set data and task end listener
40+
controller.delegate = self
41+
controller.data = taskData
42+
43+
// start task
44+
self.present(controller, animated: false, completion: nil)
45+
}
46+
47+
48+
//---------------------------------------------------------------------------
49+
func taskCallback(_ success: Bool){
50+
// handle success
51+
}
52+
}
1653
```
1754

55+
#### Objective-c
56+
57+
##### ViewController.h:
1858
```objective-c
19-
Storyboard* storyboard = [UIStoryboard storyboardWithName:@"Task" bundle: [NSBundle bundleWithIdentifier:@"com.eyesquare.frm"]];
20-
TaskViewController* controller = (TaskViewController*)[storyboard instantiateViewControllerWithIdentifier:@"TaskViewController"];
59+
#import <UIKit/UIKit.h>
60+
#import "InContextSDK/InContextSDK-Swift.h"
61+
62+
@interface ViewController : UIViewController <TaskDelegate>
2163

22-
[self presentViewController:controller animated:NO completion:nil];
64+
@end
2365
```
66+
67+
##### ViewController.m:
68+
69+
```objective-c
70+
#import "ViewController.h"
71+
72+
@interface ViewController ()
73+
@end
74+
75+
@implementation ViewController
76+
77+
...
78+
79+
//---------------------------------------------------------------------------
80+
- (IBAction)onButtonPressed:(id)sender {
81+
82+
// instantiate the controller
83+
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Task" bundle: [NSBundle bundleWithIdentifier:@"com.eyesquare.InContextSDK"]];
84+
TaskViewController* controller = (TaskViewController*)[storyboard instantiateViewControllerWithIdentifier:@"TaskViewController"];
85+
86+
// define task variables
87+
TaskData* taskData = [[TaskData alloc] initWithProjectID:@"2017-05_DE030_j2vyo5nj" SubjectGroupID:@"fbpers" UserHash:@"1234"];
88+
89+
// set data and task end listener
90+
controller.delegate = self;
91+
controller.data = taskData;
92+
93+
// start task
94+
[self presentViewController:controller animated:NO completion:nil];
95+
}
96+
97+
98+
//---------------------------------------------------------------------------
99+
- (void)taskCallback :(bool)success {
100+
// handle success
101+
}
102+
@end
103+
```
104+

0 commit comments

Comments
 (0)