@@ -65,7 +65,10 @@ public class Utils: NSObject {
65
65
" url " : url,
66
66
" params " : logEvent as Any
67
67
]
68
- SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . logEvent) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . logEvent, RequestParameterKey . notificationPayload: listenerDict] )
68
+ // Dispatch to main thread for Flutter method channel call. Platform channel messages must be sent on the platform thread to avoid data loss or crashes.
69
+ DispatchQueue . main. async {
70
+ SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . logEvent) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . logEvent, RequestParameterKey . notificationPayload: listenerDict] )
71
+ }
69
72
}
70
73
71
74
return listener
@@ -94,7 +97,10 @@ public class Utils: NSObject {
94
97
" attributes " : attributes as Any ,
95
98
" variation " : variation
96
99
]
97
- SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . activate) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . activate, RequestParameterKey . notificationPayload: listenerDict] )
100
+ // Dispatch to main thread for Flutter method channel call
101
+ DispatchQueue . main. async {
102
+ SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . activate) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . activate, RequestParameterKey . notificationPayload: listenerDict] )
103
+ }
98
104
}
99
105
return listener
100
106
}
@@ -108,7 +114,10 @@ public class Utils: NSObject {
108
114
" attributes " : attributes as Any ,
109
115
" decisionInfo " : decisionInfo
110
116
]
111
- SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . decision) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . decision, RequestParameterKey . notificationPayload: listenerDict] )
117
+ // Dispatch to main thread for Flutter method channel call
118
+ DispatchQueue . main. async {
119
+ SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . decision) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . decision, RequestParameterKey . notificationPayload: listenerDict] )
120
+ }
112
121
}
113
122
return listener
114
123
}
@@ -123,7 +132,9 @@ public class Utils: NSObject {
123
132
" userId " : userId,
124
133
// "event": event as Any, This is causing codec related exceptions on flutter side, need to debug
125
134
]
126
- SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . track) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . track, RequestParameterKey . notificationPayload: listenerDict] )
135
+ DispatchQueue . main. async {
136
+ SwiftOptimizelyFlutterSdkPlugin . channel. invokeMethod ( " \( NotificationType . track) CallbackListener " , arguments: [ RequestParameterKey . sdkKey: sdkKey, RequestParameterKey . notificationId: id, RequestParameterKey . notificationType: NotificationType . track, RequestParameterKey . notificationPayload: listenerDict] )
137
+ }
127
138
}
128
139
return listener
129
140
}
0 commit comments