Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading LocalDevice hit Unhandled Exception #491

Closed
dennislean opened this issue Oct 27, 2023 · 2 comments
Closed

loading LocalDevice hit Unhandled Exception #491

dennislean opened this issue Oct 27, 2023 · 2 comments
Assignees

Comments

@dennislean
Copy link

Issue:

On iOS, unable to get the device ID and client ID from the LocalDevice object due to unhandled exception when loading LocalDevice info.

Error Message:

Unhandled Exception: type '_Map<Object?, Object?>' is not a subtype of type 'String' in type cast

Exception throw from:

final localDevice = await _realtime.device();

Actual problem from:

(recipient != null) ? Map<String, String>.from(recipient) : null,

More details:

This problem only happen on iOS due to the recipient contains object in the value.

{
    "state": null,
    "errorReason": null,
    "recipient": {
        "transportType": "apns",
        "apnsDeviceTokens": {
            "default": "xxxxxxxxxxxxx"
        }
    }
}

However, It is working fine on Android because the recipient is a simple Map<String, String>.

{
    "recipient": {
        "transportType": "fcm",
        "registrationToken": "xxxxxxx:xxxxxxx"
    }
}

Other Info:

Flutter: 3.13.5
Device: iPhone 11 (physical device), iOS 16.6.1
Editor: VS Code
Sample code: Ably example code from latest master branch (commit: c4b8ed6)

@dennislean
Copy link
Author

Exception trace:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: type '_Map<Object?, Object?>' is not a subtype of type 'String' in type cast
#0      new LinkedHashMap.from.<anonymous closure> (dart:collection/linked_hash_map.dart:187:26)
#1      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#2      new LinkedHashMap.from (dart:collection/linked_hash_map.dart:186:11)
#3      Codec._decodeDevicePushDetails (package:ably_flutter/src/platform/src/codec.dart:799:33)
#4      Codec._decodeDeviceDetails (package:ably_flutter/src/platform/src/codec.dart:783:13)
#5      Codec._decodeLocalDevice (package:ably_flutter/src/platform/src/codec.dart:809:24)
#6      _CodecPair.decode (package:ably_flutter/src/platform/src/codec.dart:51:21)
#7      Codec.readValueOfType (package:ably_flutter/src/platform/src/codec.dart:230:19)
#8      StandardMessageCodec.readValue (package:flutter/src/services/message_codecs.dart:478:12)
#9      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:645:27)
#10     MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
<asynchronous suspension>
#11     Platform.invokePlatformMethod (package:ably_flutter/src/platform/src/platform.dart:52:14)
<asynchronous suspension>
#12     PlatformObject.invokeRequest (package:ably_flutter/src/platform/src/platform_object.dart:74:22)
<asynchronous suspension>
#13     PushNotificationService.getDevice (package:ably_flutter_example/push_notifications/push_notification_service.dart:111:27)
<asynchronous suspension>

@sync-by-unito
Copy link

sync-by-unito bot commented Oct 27, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3919

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants