App crashes when triggering an event with map data on a private channel
Opened this issue · 1 comments
Hi there
Bug Report: App crashes when triggering event with a map data type on private channel
Description
I get this error when I try to trigger an event for a private channel:
Could not cast value of type '__NSDictionaryM' (0x10e189548) to 'NSString' (0x10e1819f0).
After this error, the app crashes.
Code Sample
Here is the code I'm using that causes the error:
await _pusher.trigger(
PusherEvent(
channelName: 'private-$channelId',
eventName: 'client-$event',
data: { 'some': 'map', 'data': 'example' },
),
);
If I use a string instead of a map for the data
parameter, no error is thrown, and the event works fine:
await _pusher.trigger(
PusherEvent(
channelName: 'private-$channelId',
eventName: 'client-$event',
data: 'some string',
),
);
Additional Information
- Subscription to the channel was successful:
LOG: onEvent: { channelName: private-77a90cc0-a3a6-4d35-a7bc-ba8abaacd8eb, eventName: pusher:subscription_succeeded, data: {}, userId: null }
Expected Behavior
The data
parameter for the triggerEvent
method is of dynamic
type, so I assume it should accept different data types, including maps. I expect that using a map for data
shouldn't crash the app. Ideally, the framework should handle the error or throw an exception instead of causing a crash.
Wrapping the code in a try-catch
block did not help in catching the error.
Environment
- Platform: [iOS]
- Framework: [2.2.1]
- Language: Dart/Flutter
Also to add that I could just easily json encode the map data, but I wanted to bring it to your notice that some native platform errors are causing the app to crash.
It also happened when I was trying to join a private channel. If my backend throws an error and the authorizer doesn't complete, my app crashes. Using a try-catch block does not help. Please fix.