Interacting with the Copilot.cx SDK in Dart
Use Copilot.cx SDK through dart code
- Inside your project, create a
MethodChannel
const channel = MethodChannel('myProjectChannelName');
The Channel name should be the same on all sided (iOS, Android and Flutter).
- Add add functions that will invoke the native code through the
MethodChannel
(iOS and Android)
void _startSession(String userId) {
channel.invokeMethod("startSession", {"userId": userId, "isConsentGiven": true});
}
void _endSession() {
channel.invokeMethod("endSession");
}
void _sendEvent() {
var eventName = "eventName";
var eventParams = {
"key1": "value1",
"key2": "value2"
};
channel.invokeMethod("sendEvent", {
"eventName": eventName,
"eventParams": eventParams}
);
}