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

int value is changed to double on Android #461

Closed
Afur opened this issue Mar 21, 2023 · 5 comments · Fixed by #486
Closed

int value is changed to double on Android #461

Afur opened this issue Mar 21, 2023 · 5 comments · Fixed by #486

Comments

@Afur
Copy link
Contributor

Afur commented Mar 21, 2023

Hey, on Android I'm facing an issue where all of my int values from json passed in message as data are converted to double on Dart side.

Example:

I send as data:

object: {
   year: 2021,
} 

I receive as Message.data (only on Android, iOS works fine):

object: {
   year: 2021.0,
} 
@sync-by-unito
Copy link

sync-by-unito bot commented Mar 21, 2023

➤ Automation for Jira commented:

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

@owenpearson
Copy link
Member

Hey @Afur, thank you for raising this! We will investigate and see if there's something we can do to prevent this behaviour. The underlying cause of this problem is that the android version of ably-flutter uses Gson internally and this is just the default behaviour of Gson.

As a workaround it should be possible to publish the messages as json encoded strings and decode them in your own application code, or just simply cast the values to ints upon receipt of the message. Please let us know if you need any further help.

@Afur
Copy link
Contributor Author

Afur commented Mar 21, 2023

Thanks for the fast response, this solution looks promising. I'll check locally if the library upgrade and that as a fix works for now. Eventually, I'll submit PR with that and you'll test whether it covers all yours use cases or didn't break something.

@Afur
Copy link
Contributor Author

Afur commented Oct 13, 2023

Issue still exists I've added comment in #462. Code with fix is missing on main even when PR is merged. Probably has been removed with some merge conflicts commit

@owenpearson
Copy link
Member

Hey @Afur, thanks for raising this.

You're right that the changes in your commit were mistakenly removed during a merge, I've opened #486 to apply the changes again. Really sorry for the inconvenience here.

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

Successfully merging a pull request may close this issue.

2 participants