-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomChatViewController.m
78 lines (62 loc) · 2.83 KB
/
CustomChatViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// CustomChatViewController.m
// ChatTest
//
// Created by Stephen Kopylov - Home on 19/12/15.
// Copyright © 2015 Stephen Kopylov - Home. All rights reserved.
//
#import "CustomChatViewController.h"
#import <ZDCChat/ZDCChat.h>
@interface CustomChatViewController ()
@end
@implementation CustomChatViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIButton *testButton = [UIButton buttonWithType:UIButtonTypeSystem];
[testButton addTarget:self action:@selector(buttonTapped) forControlEvents:UIControlEventTouchUpInside];
testButton.layer.cornerRadius = 5.0f;
testButton.layer.borderWidth = 1.0f;
testButton.layer.borderColor = [testButton tintColor].CGColor;
[testButton setTitle:@"Open Chat" forState:UIControlStateNormal];
testButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:testButton];
NSDictionary *views = @{
@"button": testButton,
};
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-30-[button]-30-|" options:0 metrics:nil views:views]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-100-[button(50)]" options:0 metrics:nil views:views]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)buttonTapped
{
[ZDCChat updateVisitor:^(ZDCVisitorInfo *visitor) {
visitor.phone = [NSString stringWithFormat:@"%lu", (long)[[NSDate date] timeIntervalSince1970]];
visitor.name = [NSString stringWithFormat:@"iOs Chat Test %lu", (long)[[NSDate date] timeIntervalSince1970]];
visitor.email = [NSString stringWithFormat:@"chattest+%[email protected]", (long)[[NSDate date] timeIntervalSince1970]];
}];
// start a chat in a new modal
//[ZDCChat startChat:nil];
[ZDCChat startChat:^(ZDCSessionConfig *config) {
config.preChatDataRequirements.name = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.email = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.phone = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.department = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.message = ZDCPreChatDataNotRequired;
}];
/*
[ZDCChat startChatIn:self.navigationController withConfig:^(ZDCSessionConfig *config) {
config.preChatDataRequirements.name = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.email = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.phone = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.department = ZDCPreChatDataNotRequired;
config.preChatDataRequirements.message = ZDCPreChatDataNotRequired;
}];
*/
}
@end