From 09c32758e62816e0c74e8c0bd452134c43522569 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Fri, 23 Feb 2024 21:10:41 +0530 Subject: [PATCH] Added realtime callback whenever connection state changes, send connection id --- ios/Classes/AblyFlutter.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ios/Classes/AblyFlutter.m b/ios/Classes/AblyFlutter.m index 8f6b33a91..b25dd9062 100644 --- a/ios/Classes/AblyFlutter.m +++ b/ios/Classes/AblyFlutter.m @@ -263,6 +263,13 @@ -(void)reset; ARTRealtime *const realtime = [[ARTRealtime alloc] initWithOptions:options.clientOptions]; [instanceStore setRealtime:realtime with:handle]; + [realtime.connection on:^(ARTConnectionStateChange *stateChange) { + AblyFlutterMessage *const message + = [[AblyFlutterMessage alloc] initWithMessage:[realtime.connection id] handle: handle]; + [ably.channel invokeMethod:AblyPlatformMethod_connectionIdUpdated + arguments:message] + }]; + // Giving Ably client the deviceToken registered at device launch (didRegisterForRemoteNotificationsWithDeviceToken). // This is not an ideal solution. We save the deviceToken given in didRegisterForRemoteNotificationsWithDeviceToken and the // error in didFailToRegisterForRemoteNotificationsWithError and pass it to Ably in the first client that is first created.