-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7174b9a
commit ba26dee
Showing
4 changed files
with
78 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Flutter | ||
import LiveChat | ||
|
||
class EmbeddedChatView: NSObject, FlutterPlatformView { | ||
private var chatWindow: UIView | ||
|
||
init(frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?, binaryMessenger messenger: FlutterBinaryMessenger?) { | ||
self.chatWindow = UIView(frame: frame) | ||
super.init() | ||
|
||
let params = args as! [String: Any] | ||
let licenseNo = params["licenseNo"] as? String ?? "" | ||
let groupId = params["groupId"] as? String | ||
let visitorName = params["visitorName"] as? String ?? "" | ||
let visitorEmail = params["visitorEmail"] as? String ?? "" | ||
let customParams = params["customParams"] as? [String: String] ?? [:] | ||
|
||
LiveChat.licenseId = licenseNo | ||
LiveChat.groupId = groupId | ||
LiveChat.name = visitorName | ||
LiveChat.email = visitorEmail | ||
|
||
for (key, value) in customParams { | ||
LiveChat.setVariable(withKey: key, value: value) | ||
} | ||
|
||
LiveChat.presentChat() | ||
} | ||
|
||
func view() -> UIView { | ||
return chatWindow | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Flutter | ||
import UIKit | ||
|
||
class EmbeddedChatViewFactory: NSObject, FlutterPlatformViewFactory { | ||
private var messenger: FlutterBinaryMessenger | ||
|
||
init(messenger: FlutterBinaryMessenger) { | ||
self.messenger = messenger | ||
super.init() | ||
} | ||
|
||
func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> FlutterPlatformView { | ||
return EmbeddedChatView(frame: frame, viewIdentifier: viewId, arguments: args, binaryMessenger: messenger) | ||
} | ||
|
||
public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol { | ||
return FlutterStandardMessageCodec.sharedInstance() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters