diff --git a/android/build.gradle b/android/build.gradle index a60ef6170..e56d4b71f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -23,7 +23,7 @@ apply plugin: 'com.android.library' dependencies { // https://github.com/ably/ably-java/ - implementation 'io.ably:ably-android:1.2.33' + implementation 'io.ably:ably-android:1.2.35' // https://firebase.google.com/docs/cloud-messaging/android/client implementation 'com.google.firebase:firebase-messaging:23.0.4' diff --git a/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java b/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java index 2d90d3571..368e8e1dc 100644 --- a/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java +++ b/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java @@ -112,6 +112,9 @@ public AblyMethodCallHandler(final MethodChannel methodChannel, _map.put(PlatformConstants.PlatformMethod.restAuthGetClientId, (methodCall, result) -> authMethodHandler.clientId(methodCall, result, AuthMethodHandler.Type.Rest)); + // Connection specific handlers + _map.put(PlatformConstants.PlatformMethod.connectionRecoveryKey, this::connectionRecoveryKey); + // Push Notifications _map.put(PlatformConstants.PlatformMethod.pushActivate, this::pushActivate); _map.put(PlatformConstants.PlatformMethod.pushDeactivate, this::pushDeactivate); @@ -551,14 +554,17 @@ private void realtimeTime(@NonNull MethodCall methodCall, @NonNull MethodChannel time(result, instanceStore.getRealtime(ablyMessage.handle)); } - - - - private void restTime(@NonNull MethodCall methodCall, @NonNull MethodChannel.Result result) { + private void restTime(@NonNull MethodCall methodCall, @NonNull MethodChannel.Result result) { final AblyFlutterMessage ablyMessage = (AblyFlutterMessage) methodCall.arguments; time(result, instanceStore.getRest(ablyMessage.handle)); } + private void connectionRecoveryKey(@NonNull MethodCall methodCall, @NonNull MethodChannel.Result result) { + final AblyFlutterMessage ablyMessage = (AblyFlutterMessage) methodCall.arguments; + AblyRealtime realtime = instanceStore.getRealtime(ablyMessage.handle); + result.success(realtime.connection.createRecoveryKey()); + } + private void time(@NonNull MethodChannel.Result result, AblyBase client) { Callback callback = new Callback() { @Override diff --git a/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java b/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java index 0daae8124..06b0e2bf3 100644 --- a/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java +++ b/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java @@ -77,6 +77,9 @@ static final public class PlatformMethod { public static final String realtimeAuthCreateTokenRequest = "realtimeAuthCreateTokenRequest"; public static final String realtimeAuthRequestToken = "realtimeAuthRequestToken"; public static final String realtimeAuthGetClientId = "realtimeAuthGetClientId"; + + public static final String connectionRecoveryKey = "connectionRecoveryKey"; + public static final String pushActivate = "pushActivate"; public static final String pushDeactivate = "pushDeactivate"; public static final String pushReset = "pushReset"; diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ddcf4a9ee..6a9f8b7e1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - - Ably (1.2.24): + - Ably (1.2.25): - AblyDeltaCodec (= 1.3.3) - msgpack (= 0.4.0) - ably_flutter (1.2.26): - - Ably (= 1.2.24) + - Ably (= 1.2.25) - Flutter - AblyDeltaCodec (1.3.3) - device_info_plus (0.0.1): diff --git a/example/lib/ui/realtime_sliver.dart b/example/lib/ui/realtime_sliver.dart index 0481c9175..15e143e5c 100644 --- a/example/lib/ui/realtime_sliver.dart +++ b/example/lib/ui/realtime_sliver.dart @@ -136,13 +136,15 @@ class RealtimeSliver extends HookWidget { ValueNotifier connectionState, ValueNotifier channelState, ValueNotifier connectionId, + ValueNotifier recoveryKey, ) => TextButton( onPressed: () async { await channel.detach(); realtime.channels.release(Constants.channelName); channel = realtime.channels.get(Constants.channelName); - setupListeners(connectionState, channelState, connectionId); + setupListeners( + connectionState, channelState, connectionId, recoveryKey); }, child: const Text('Release'), ); @@ -179,6 +181,7 @@ class RealtimeSliver extends HookWidget { final connectionState = useState(realtime.connection.state); final connectionId = useState(realtime.connection.id); + final recoveryKey = useState(''); final channelState = useState(channel.state); final latestMessage = useState(null); final channelSubscription = @@ -188,7 +191,7 @@ class RealtimeSliver extends HookWidget { useEffect(() { realtime.time().then((value) => realtimeTime.value = value); - setupListeners(connectionState, channelState, connectionId); + setupListeners(connectionState, channelState, connectionId, recoveryKey); return dispose; }, []); @@ -202,6 +205,7 @@ class RealtimeSliver extends HookWidget { Text('Realtime time: ${realtimeTime.value}'), Text('Connection State: ${connectionState.value}'), Text('Connection Id: ${connectionId.value ?? '-'}'), + Text('Connection Recovery Key: ${recoveryKey.value ?? '-'}'), buildEncryptionSwitch(useEncryption), Row( children: [ @@ -226,7 +230,7 @@ class RealtimeSliver extends HookWidget { Expanded(child: buildChannelDetachButton(channelState.value)), Expanded( child: buildReleaseRealtimeChannelButton( - connectionState, channelState, connectionId)), + connectionState, channelState, connectionId, recoveryKey)), ], ), Row( @@ -293,7 +297,8 @@ class RealtimeSliver extends HookWidget { void setupListeners( ValueNotifier connectionState, ValueNotifier channelState, - ValueNotifier connectionId) { + ValueNotifier connectionId, + ValueNotifier recoveryKey) { dispose(); final connectionSubscription = realtime.connection.on().listen((connectionStateChange) { @@ -302,6 +307,9 @@ class RealtimeSliver extends HookWidget { } connectionState.value = connectionStateChange.current; connectionId.value = realtime.connection.id; + realtime.connection + .createRecoveryKey() + .then((value) => {recoveryKey.value = value}); print('${DateTime.now()}:' ' ConnectionStateChange event: ${connectionStateChange.event}' '\nReason: ${connectionStateChange.reason}'); diff --git a/ios/Classes/AblyFlutter.m b/ios/Classes/AblyFlutter.m index e465407d8..d02602b20 100644 --- a/ios/Classes/AblyFlutter.m +++ b/ios/Classes/AblyFlutter.m @@ -599,6 +599,14 @@ -(void)reset; }]; }; +static const FlutterHandler _connectionRecoveryKey = ^void(AblyFlutter *const ably, FlutterMethodCall *const call, const FlutterResult result) { + AblyFlutterMessage *const ablyMessage = call.arguments; + AblyInstanceStore *const instanceStore = [ably instanceStore]; + ARTRealtime *const realtime = [instanceStore realtimeFrom:ablyMessage.handle]; + NSString *const connectionRecoveryKey = [realtime.connection createRecoveryKey]; + result(connectionRecoveryKey); +}; + static const FlutterHandler _getNextPage = ^void(AblyFlutter *const ably, FlutterMethodCall *const call, const FlutterResult result) { AblyFlutterMessage *const ablyMessage = call.arguments; @@ -741,6 +749,8 @@ -(instancetype)initWithChannel:(FlutterMethodChannel *const)channel AblyPlatformMethod_releaseRealtimeChannel: _releaseRealtimeChannel, AblyPlatformMethod_realtimeTime:_realtimeTime, AblyPlatformMethod_restTime:_restTime, + // Connection fields + AblyPlatformMethod_connectionRecoveryKey:_connectionRecoveryKey, // Push Notifications AblyPlatformMethod_pushActivate: PushHandlers.activate, AblyPlatformMethod_pushRequestPermission: PushHandlers.requestPermission, diff --git a/ios/Classes/codec/AblyPlatformConstants.h b/ios/Classes/codec/AblyPlatformConstants.h index c49d316e4..b733bcefd 100644 --- a/ios/Classes/codec/AblyPlatformConstants.h +++ b/ios/Classes/codec/AblyPlatformConstants.h @@ -75,6 +75,9 @@ extern NSString *const AblyPlatformMethod_realtimeAuthAuthorize; extern NSString *const AblyPlatformMethod_realtimeAuthCreateTokenRequest; extern NSString *const AblyPlatformMethod_realtimeAuthRequestToken; extern NSString *const AblyPlatformMethod_realtimeAuthGetClientId; + +extern NSString *const AblyPlatformMethod_connectionRecoveryKey; + extern NSString *const AblyPlatformMethod_pushActivate; extern NSString *const AblyPlatformMethod_pushDeactivate; extern NSString *const AblyPlatformMethod_pushReset; diff --git a/ios/Classes/codec/AblyPlatformConstants.m b/ios/Classes/codec/AblyPlatformConstants.m index 128c368ed..36061c488 100644 --- a/ios/Classes/codec/AblyPlatformConstants.m +++ b/ios/Classes/codec/AblyPlatformConstants.m @@ -44,6 +44,9 @@ NSString *const AblyPlatformMethod_realtimeAuthCreateTokenRequest= @"realtimeAuthCreateTokenRequest"; NSString *const AblyPlatformMethod_realtimeAuthRequestToken= @"realtimeAuthRequestToken"; NSString *const AblyPlatformMethod_realtimeAuthGetClientId= @"realtimeAuthGetClientId"; + +NSString *const AblyPlatformMethod_connectionRecoveryKey = @"connectionRecoveryKey"; + NSString *const AblyPlatformMethod_pushActivate= @"pushActivate"; NSString *const AblyPlatformMethod_pushDeactivate= @"pushDeactivate"; NSString *const AblyPlatformMethod_pushReset= @"pushReset"; diff --git a/ios/ably_flutter.podspec b/ios/ably_flutter.podspec index bfdbc0721..c331a8c59 100644 --- a/ios/ably_flutter.podspec +++ b/ios/ably_flutter.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'Ably', '1.2.24' + s.dependency 'Ably', '1.2.25' s.platform = :ios s.ios.deployment_target = '10.0' diff --git a/lib/src/generated/platform_constants.dart b/lib/src/generated/platform_constants.dart index 35c47bb76..3c3e2d67e 100644 --- a/lib/src/generated/platform_constants.dart +++ b/lib/src/generated/platform_constants.dart @@ -76,6 +76,9 @@ class PlatformMethod { 'realtimeAuthCreateTokenRequest'; static const String realtimeAuthRequestToken = 'realtimeAuthRequestToken'; static const String realtimeAuthGetClientId = 'realtimeAuthGetClientId'; + + static const String connectionRecoveryKey = 'connectionRecoveryKey'; + static const String pushActivate = 'pushActivate'; static const String pushDeactivate = 'pushDeactivate'; static const String pushReset = 'pushReset'; diff --git a/lib/src/platform/src/realtime/connection.dart b/lib/src/platform/src/realtime/connection.dart index 0777555d0..b1dce0142 100644 --- a/lib/src/platform/src/realtime/connection.dart +++ b/lib/src/platform/src/realtime/connection.dart @@ -61,8 +61,17 @@ class Connection extends PlatformObject { /// /// See [connection state recover options](https://ably.com/docs/realtime/connection#connection-state-recover-options) /// for more information. + @Deprecated('Use createRecoveryKey instead') String? recoveryKey; + /// The createRecoveryKey returns key string can be used by another client to + /// recover this connection's state in the recover client options property. + /// + /// See [connection state recover options](https://ably.com/docs/realtime/connection#connection-state-recover-options) + /// for more information. + Future createRecoveryKey() => + invoke(PlatformMethod.connectionRecoveryKey); + /// The serial number of the last message to be received on this connection, /// used automatically by the library when recovering or resuming a /// connection. diff --git a/test_integration/ios/Podfile.lock b/test_integration/ios/Podfile.lock index cb58e2458..6d7658b71 100644 --- a/test_integration/ios/Podfile.lock +++ b/test_integration/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - - Ably (1.2.24): + - Ably (1.2.25): - AblyDeltaCodec (= 1.3.3) - msgpack (= 0.4.0) - ably_flutter (1.2.26): - - Ably (= 1.2.24) + - Ably (= 1.2.25) - Flutter - AblyDeltaCodec (1.3.3) - Flutter (1.0.0) diff --git a/test_integration/lib/test/realtime/realtime_auth_client_id_test.dart b/test_integration/lib/test/realtime/realtime_auth_client_id_test.dart index e94781380..9575bc6d4 100644 --- a/test_integration/lib/test/realtime/realtime_auth_client_id_test.dart +++ b/test_integration/lib/test/realtime/realtime_auth_client_id_test.dart @@ -13,7 +13,7 @@ Future> testRealtimeAuthClientId({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final ablyForToken = Rest( diff --git a/test_integration/lib/test/realtime/realtime_auth_url_test.dart b/test_integration/lib/test/realtime/realtime_auth_url_test.dart index 8aacb9878..cea621364 100644 --- a/test_integration/lib/test/realtime/realtime_auth_url_test.dart +++ b/test_integration/lib/test/realtime/realtime_auth_url_test.dart @@ -16,7 +16,7 @@ Future> testCreateRealtimeWithAuthUrl({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, fallbackHosts: ['a.ably-realtime.com', 'b.ably-realtime.com'], ); @@ -32,7 +32,7 @@ Future> testCreateRealtimeWithAuthUrl({ environment: 'sandbox', useTokenAuth: true, autoConnect: false, - logLevel: LogLevel.verbose); + logLevel: LogLevel.error); final realtime = Realtime(options: options); final completer = Completer(); realtime.connection.on().listen((stateChange) { diff --git a/test_integration/lib/test/realtime/realtime_authorize_test.dart b/test_integration/lib/test/realtime/realtime_authorize_test.dart index b85136b0a..c7497c16c 100644 --- a/test_integration/lib/test/realtime/realtime_authorize_test.dart +++ b/test_integration/lib/test/realtime/realtime_authorize_test.dart @@ -13,7 +13,7 @@ Future> testRealtimeAuthroize({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final ablyForToken = Rest( diff --git a/test_integration/lib/test/realtime/realtime_encrypted_publish_test.dart b/test_integration/lib/test/realtime/realtime_encrypted_publish_test.dart index 0354fab78..dee384131 100644 --- a/test_integration/lib/test/realtime/realtime_encrypted_publish_test.dart +++ b/test_integration/lib/test/realtime/realtime_encrypted_publish_test.dart @@ -52,7 +52,7 @@ Future> testRealtimeEncryptedPublishSpec({ key: appKey, environment: 'sandbox', clientId: clientId, - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); diff --git a/test_integration/lib/test/realtime/realtime_history_test.dart b/test_integration/lib/test/realtime/realtime_history_test.dart index a99029fc6..f514a52b9 100644 --- a/test_integration/lib/test/realtime/realtime_history_test.dart +++ b/test_integration/lib/test/realtime/realtime_history_test.dart @@ -17,7 +17,7 @@ Future> testRealtimeHistory({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); final channel = realtime.channels.get('test'); diff --git a/test_integration/lib/test/realtime/realtime_history_with_auth_callback_test.dart b/test_integration/lib/test/realtime/realtime_history_with_auth_callback_test.dart index 85a69e0a1..4bfe35013 100644 --- a/test_integration/lib/test/realtime/realtime_history_with_auth_callback_test.dart +++ b/test_integration/lib/test/realtime/realtime_history_with_auth_callback_test.dart @@ -13,7 +13,7 @@ Future> testRealtimeHistoryWithAuthCallback({ final realtime = Realtime( options: ClientOptions( clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, authCallback: (params) async { authCallbackInvoked = true; return TokenRequest.fromMap( diff --git a/test_integration/lib/test/realtime/realtime_presence_enter_update_leave.dart b/test_integration/lib/test/realtime/realtime_presence_enter_update_leave.dart index ee7baf954..94b8699cf 100644 --- a/test_integration/lib/test/realtime/realtime_presence_enter_update_leave.dart +++ b/test_integration/lib/test/realtime/realtime_presence_enter_update_leave.dart @@ -14,7 +14,7 @@ ClientOptions getClientOptions( key: appKey, environment: 'sandbox', clientId: clientId, - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); Future> testRealtimePresenceEnterUpdateLeave({ diff --git a/test_integration/lib/test/realtime/realtime_presence_get.dart b/test_integration/lib/test/realtime/realtime_presence_get.dart index 327938a09..95adb8cd7 100644 --- a/test_integration/lib/test/realtime/realtime_presence_get.dart +++ b/test_integration/lib/test/realtime/realtime_presence_get.dart @@ -15,7 +15,7 @@ ClientOptions getClientOptions( key: appKey, environment: 'sandbox', clientId: clientId, - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); Future> testRealtimePresenceGet({ diff --git a/test_integration/lib/test/realtime/realtime_presence_history_test.dart b/test_integration/lib/test/realtime/realtime_presence_history_test.dart index 68a752e88..530a6d9f4 100644 --- a/test_integration/lib/test/realtime/realtime_presence_history_test.dart +++ b/test_integration/lib/test/realtime/realtime_presence_history_test.dart @@ -17,7 +17,7 @@ Future> testRealtimePresenceHistory({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final realtime = Realtime(options: options); diff --git a/test_integration/lib/test/realtime/realtime_presence_subscribe.dart b/test_integration/lib/test/realtime/realtime_presence_subscribe.dart index b45dc1186..c8842bffa 100644 --- a/test_integration/lib/test/realtime/realtime_presence_subscribe.dart +++ b/test_integration/lib/test/realtime/realtime_presence_subscribe.dart @@ -23,7 +23,7 @@ Future> testRealtimePresenceSubscribe({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ).channels.get('test').presence; diff --git a/test_integration/lib/test/realtime/realtime_publish_test.dart b/test_integration/lib/test/realtime/realtime_publish_test.dart index c23173635..14ed51ea7 100644 --- a/test_integration/lib/test/realtime/realtime_publish_test.dart +++ b/test_integration/lib/test/realtime/realtime_publish_test.dart @@ -18,7 +18,7 @@ Future> testRealtimePublish({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); await publishMessages(realtime.channels.get('test')); @@ -40,7 +40,7 @@ Future> testRealtimePublishSpec({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); final channel = realtime.channels.get('test'); diff --git a/test_integration/lib/test/realtime/realtime_publish_with_auth_callback_test.dart b/test_integration/lib/test/realtime/realtime_publish_with_auth_callback_test.dart index 7207d4a8d..669994bbe 100644 --- a/test_integration/lib/test/realtime/realtime_publish_with_auth_callback_test.dart +++ b/test_integration/lib/test/realtime/realtime_publish_with_auth_callback_test.dart @@ -10,7 +10,7 @@ Future> testRealtimePublishWithAuthCallback({ var authCallbackInvoked = false; final realtime = Realtime( options: ClientOptions( - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, authCallback: (params) async { authCallbackInvoked = true; return TokenRequest.fromMap( diff --git a/test_integration/lib/test/realtime/realtime_time_test.dart b/test_integration/lib/test/realtime/realtime_time_test.dart index 7a8bf17d3..873e68f53 100644 --- a/test_integration/lib/test/realtime/realtime_time_test.dart +++ b/test_integration/lib/test/realtime/realtime_time_test.dart @@ -14,7 +14,7 @@ Future> testRealtimeTime({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); diff --git a/test_integration/lib/test/rest/rest_auth_client_id_test.dart b/test_integration/lib/test/rest/rest_auth_client_id_test.dart index 32eefa261..3cfcafea8 100644 --- a/test_integration/lib/test/rest/rest_auth_client_id_test.dart +++ b/test_integration/lib/test/rest/rest_auth_client_id_test.dart @@ -13,7 +13,7 @@ Future> testRestAuthClientId({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final ablyForToken = Rest( diff --git a/test_integration/lib/test/rest/rest_authorize_test.dart b/test_integration/lib/test/rest/rest_authorize_test.dart index c0f636326..44621ff21 100644 --- a/test_integration/lib/test/rest/rest_authorize_test.dart +++ b/test_integration/lib/test/rest/rest_authorize_test.dart @@ -13,7 +13,7 @@ Future> testRestAuthorize({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final ablyForToken = Rest( diff --git a/test_integration/lib/test/rest/rest_capability_test.dart b/test_integration/lib/test/rest/rest_capability_test.dart index d11f73cfd..cb4a49097 100644 --- a/test_integration/lib/test/rest/rest_capability_test.dart +++ b/test_integration/lib/test/rest/rest_capability_test.dart @@ -24,7 +24,7 @@ Future> testRestCapabilities({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); diff --git a/test_integration/lib/test/rest/rest_create_token_request_test.dart b/test_integration/lib/test/rest/rest_create_token_request_test.dart index a94f5bcd4..38d106b8d 100644 --- a/test_integration/lib/test/rest/rest_create_token_request_test.dart +++ b/test_integration/lib/test/rest/rest_create_token_request_test.dart @@ -12,7 +12,7 @@ Future> testRestCreateTokenRequest({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final rest = Rest( diff --git a/test_integration/lib/test/rest/rest_encrypted_publish_test.dart b/test_integration/lib/test/rest/rest_encrypted_publish_test.dart index 09fbad32f..44500d32e 100644 --- a/test_integration/lib/test/rest/rest_encrypted_publish_test.dart +++ b/test_integration/lib/test/rest/rest_encrypted_publish_test.dart @@ -22,7 +22,7 @@ Future> testRestEncryptedPublish({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); @@ -53,7 +53,7 @@ Future> testRestEncryptedPublishSpec({ key: appKey, environment: 'sandbox', clientId: clientId, - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); diff --git a/test_integration/lib/test/rest/rest_history_test.dart b/test_integration/lib/test/rest/rest_history_test.dart index 9a390d923..b84c0511c 100644 --- a/test_integration/lib/test/rest/rest_history_test.dart +++ b/test_integration/lib/test/rest/rest_history_test.dart @@ -17,7 +17,7 @@ Future> testRestHistory({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); final channel = rest.channels.get('test'); diff --git a/test_integration/lib/test/rest/rest_history_with_auth_callback_test.dart b/test_integration/lib/test/rest/rest_history_with_auth_callback_test.dart index 2e8cbe63b..c5bed7103 100644 --- a/test_integration/lib/test/rest/rest_history_with_auth_callback_test.dart +++ b/test_integration/lib/test/rest/rest_history_with_auth_callback_test.dart @@ -13,7 +13,7 @@ Future> testRestHistoryWithAuthCallback({ final rest = Rest( options: ClientOptions( clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, authCallback: (params) async { authCallbackInvoked = true; return TokenRequest.fromMap( diff --git a/test_integration/lib/test/rest/rest_presence_get_test.dart b/test_integration/lib/test/rest/rest_presence_get_test.dart index fcbfad1ea..f9ce698fe 100644 --- a/test_integration/lib/test/rest/rest_presence_get_test.dart +++ b/test_integration/lib/test/rest/rest_presence_get_test.dart @@ -15,7 +15,7 @@ ClientOptions getClientOptions( key: appKey, environment: 'sandbox', clientId: clientId, - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); Future> testRestPresenceGet({ diff --git a/test_integration/lib/test/rest/rest_presence_history_test.dart b/test_integration/lib/test/rest/rest_presence_history_test.dart index 6c2dda5bf..41b8895c3 100644 --- a/test_integration/lib/test/rest/rest_presence_history_test.dart +++ b/test_integration/lib/test/rest/rest_presence_history_test.dart @@ -17,7 +17,7 @@ Future> testRestPresenceHistory({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final rest = Rest(options: options); diff --git a/test_integration/lib/test/rest/rest_publish_test.dart b/test_integration/lib/test/rest/rest_publish_test.dart index 296a085f4..ef2cb78c9 100644 --- a/test_integration/lib/test/rest/rest_publish_test.dart +++ b/test_integration/lib/test/rest/rest_publish_test.dart @@ -19,7 +19,7 @@ Future> testRestPublish({ key: appKey.toString(), environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); await publishMessages(rest.channels.get('test')); @@ -40,7 +40,7 @@ Future> testRestPublishSpec({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); final channel = rest.channels.get('test'); diff --git a/test_integration/lib/test/rest/rest_publish_with_auth_callback_test.dart b/test_integration/lib/test/rest/rest_publish_with_auth_callback_test.dart index 0b91dd767..5ad52f173 100644 --- a/test_integration/lib/test/rest/rest_publish_with_auth_callback_test.dart +++ b/test_integration/lib/test/rest/rest_publish_with_auth_callback_test.dart @@ -12,7 +12,7 @@ Future> testRestPublishWithAuthCallback({ final rest = Rest( options: ClientOptions( clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, authCallback: (params) async { authCallbackInvoked = true; return TokenRequest.fromMap( diff --git a/test_integration/lib/test/rest/rest_request_token_test.dart b/test_integration/lib/test/rest/rest_request_token_test.dart index b1b179fb1..b6c804efd 100644 --- a/test_integration/lib/test/rest/rest_request_token_test.dart +++ b/test_integration/lib/test/rest/rest_request_token_test.dart @@ -14,7 +14,7 @@ Future> testRestRequestToken({ final clientOptionsForToken = ClientOptions( key: appKey, environment: 'sandbox', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ); final restForToken = Rest( @@ -24,7 +24,7 @@ Future> testRestRequestToken({ final token = await restForToken.auth.requestToken(); final clientOptions = ClientOptions( - tokenDetails: token, environment: 'sandbox', logLevel: LogLevel.verbose); + tokenDetails: token, environment: 'sandbox', logLevel: LogLevel.error); final tokenedRest = Rest(options: clientOptions); await publishMessages(tokenedRest.channels.get('test')); diff --git a/test_integration/lib/test/rest/rest_time_test.dart b/test_integration/lib/test/rest/rest_time_test.dart index 1c12fd928..4d840dddb 100644 --- a/test_integration/lib/test/rest/rest_time_test.dart +++ b/test_integration/lib/test/rest/rest_time_test.dart @@ -14,7 +14,7 @@ Future> testRestTime({ key: appKey, environment: 'sandbox', clientId: 'someClientId', - logLevel: LogLevel.verbose, + logLevel: LogLevel.error, ), ); diff --git a/test_integration/test_driver/test_implementation/realtime_tests.dart b/test_integration/test_driver/test_implementation/realtime_tests.dart index 5a03b10ca..e1604b506 100644 --- a/test_integration/test_driver/test_implementation/realtime_tests.dart +++ b/test_integration/test_driver/test_implementation/realtime_tests.dart @@ -316,44 +316,57 @@ void testRealtimeEvents(FlutterDriver Function() getDriver) { // TODO(tiholic): get rid of _stateChangeEvents and _stateChangePrevious // variables as they are a way to make tests pass due to // https://github.com/ably/ably-flutter/issues/63 - List _stateChangeEvents; + List _stateChangeCurrent; List _stateChangePrevious; - if (channelStateChanges.length == 5) { - // ios - _stateChangeEvents = const [ + List _stateChangeEvents; + if (channelStateChanges.length == 4) { + // iOS + _stateChangeCurrent = const [ 'attaching', 'attached', 'detaching', 'detached', - 'detached', ]; _stateChangePrevious = const [ 'initialized', 'attaching', 'attached', 'detaching', - 'detached', ]; + _stateChangeEvents = _stateChangeCurrent; } else { - _stateChangeEvents = const [ + // android + _stateChangeCurrent = const [ + 'attaching', 'attaching', 'attached', + 'attached', 'detaching', 'detached', ]; _stateChangePrevious = const [ 'initialized', 'attaching', + 'attaching', + 'attached', 'attached', 'detaching', ]; + _stateChangeEvents = const [ + 'attaching', + 'attaching', + 'attached', + 'update', + 'detaching', + 'detached', + ]; } expect(channelStateChanges.map((e) => e['event']), orderedEquals(_stateChangeEvents)); expect(channelStateChanges.map((e) => e['current']), - orderedEquals(_stateChangeEvents)); + orderedEquals(_stateChangeCurrent)); expect(channelStateChanges.map((e) => e['previous']), orderedEquals(_stateChangePrevious)); @@ -364,15 +377,38 @@ void testRealtimeEvents(FlutterDriver Function() getDriver) { '#on returns a stream which can be subscribed' ' for channel state changes with filter', () { + List _stateChangeCurrent; + List _stateChangePrevious; + List _stateChangeEvents; + if (channelStateChanges.length == 4) { + // iOS + _stateChangeCurrent = const [ + 'attaching', + ]; + _stateChangePrevious = const [ + 'initialized', + ]; + } else { + // Android + _stateChangeCurrent = const [ + 'attaching', + 'attaching', + ]; + _stateChangePrevious = const [ + 'initialized', + 'attaching', + ]; + } + _stateChangeEvents = _stateChangeCurrent; // filteredChannelStateChanges expect(filteredChannelStateChanges.map((e) => e['event']), - orderedEquals(const ['attaching'])); + orderedEquals(_stateChangeEvents)); expect(filteredChannelStateChanges.map((e) => e['current']), - orderedEquals(const ['attaching'])); + orderedEquals(_stateChangeCurrent)); expect(filteredChannelStateChanges.map((e) => e['previous']), - orderedEquals(const ['initialized'])); + orderedEquals(_stateChangePrevious)); }, ); });