Skip to content

Commit

Permalink
Fixed restTime method message handling on iOS side
Browse files Browse the repository at this point in the history
  • Loading branch information
ikurek committed Feb 8, 2022
1 parent 41f2d41 commit 38df5e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ios/Classes/AblyFlutter.m
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ -(void)reset;
static const FlutterHandler _restTime = ^void(AblyFlutter *const ably, FlutterMethodCall *const call, const FlutterResult result) {
AblyFlutterMessage *const message = call.arguments;
AblyInstanceStore *const instanceStore = [ably instanceStore];

ARTRest *const rest = [instanceStore restFrom:message.message];
NSNumber *const handle = message.message;
ARTRest *const rest = [instanceStore restFrom:handle];
[rest time:^(NSDate * _Nullable dateTimeResult, NSError * _Nullable error) {
if(error){
result(error);
Expand Down Expand Up @@ -694,7 +694,7 @@ -(instancetype)initWithChannel:(FlutterMethodChannel *const)channel
AblyPlatformMethod_realtimePresenceLeave: _leaveRealtimePresence,
AblyPlatformMethod_releaseRealtimeChannel: _releaseRealtimeChannel,
AblyPlatformMethod_realtimeTime:_realtimeTime,
AblyPlatformMethod_realtimeTime:_restTime,
AblyPlatformMethod_restTime:_restTime,
// Push Notifications
AblyPlatformMethod_pushActivate: PushHandlers.activate,
AblyPlatformMethod_pushRequestPermission: PushHandlers.requestPermission,
Expand Down
24 changes: 23 additions & 1 deletion lib/src/platform/src/platform_object.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:ably_flutter/ably_flutter.dart';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';

/// A representation of a Platform side instance (Android, iOS).
Expand Down Expand Up @@ -59,6 +58,29 @@ abstract class PlatformObject {
}

/// invoke platform method channel with AblyMessage encapsulation
/* FIXME(ikurek): This seems wrong - the structure is either
{
message: {
message: argument,
handle: handle,
type: null
},
handle: null,
type: null
}
or
{
message: handle,
handle: null,
type: null
}
Which means that the structure is wrong every time, but I can't
understand why and it seems that iOS/Android code reads handle from
message field, so I don't want to touch it now
*/
Future<T?> invoke<T>(final String method, [final Object? argument]) async {
final _handle = await handle;
final message = (null != argument)
Expand Down

0 comments on commit 38df5e5

Please sign in to comment.