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

The method "setInt" doesn't work on Android devices #5

Closed
loicparent opened this issue Oct 3, 2022 · 9 comments
Closed

The method "setInt" doesn't work on Android devices #5

loicparent opened this issue Oct 3, 2022 · 9 comments

Comments

@loicparent
Copy link

Hello @riderx,

I noticed that the method setInt() works fine with IOS devices and with desktop browsers but, it seems to be an issue with the Android devices. When I call this function as in my exemple below, the data is not sent to the Crisp website.

CapacitorCrisp.setInt({
  key: 'test',
  value: 123
});

I don't know if this is related to this plugin or if it's related to the native Crisp SDK but I informe you here :)

Kind regards,
Loïc

@riderx
Copy link
Collaborator

riderx commented Oct 3, 2022

Thanks for the feedback @loicparent, something a bit odd in the native SDK is the chat have to be open in native to allow any data to be sent.
Did you had the chat open before sending ?

@loicparent
Copy link
Author

loicparent commented Oct 3, 2022

In fact, I call multiple functions one by one in a main function like this example:

CapacitorCrisp.setUser(); // ✅
CapacitorCrisp.openMessenger(); // ✅
CapacitorCrisp.setSegment(); // ✅
CapacitorCrisp.setString(); // ✅
CapacitorCrisp.setInt(); // ❌
CapacitorCrisp.setString(); // ✅

So the chat should be opened but I don't wait till the promise (of openMessenger) finishes before calling the other functions.

@riderx
Copy link
Collaborator

riderx commented Oct 3, 2022

Thanks for the details, i did check the swift code, and it's the same structure for setString and setInt see below
CleanShot 2022-10-03 at 22 56 28@2x
CleanShot 2022-10-03 at 22 56 36@2x
Value is got with getInt as it's the type we see in their doc here https://docs.crisp.chat/guides/chatbox-sdks/ios-sdk/
So I believe the SDK has issue or they doc is wrong.
Can you report that to they github : https://github.com/crisp-im/crisp-sdk-ios/issues
and link this issue in the issue you create.
It will allow me to answer if needed.
PS: if you can edit your example with the data you send that will help them to see you are sending the right type too

@loicparent
Copy link
Author

loicparent commented Oct 4, 2022

Hello @riderx,

Thank you for your help 😃

This is not an issue with IOS but an issue with Android.
After looking through the code, I thing I found what is wrong :)

In the Android code, the type of the expected value for the function setInt() is String instead of int.
You can see it in the file CapacitorCrispPlugin.java:

demo

@loicparent
Copy link
Author

I just tried modifying the code a bit and it works :)

Here are the changes I made:

demo-2

@riderx
Copy link
Collaborator

riderx commented Oct 4, 2022

oh good catch, you want to do to a PR ?

@riderx riderx closed this as completed in 8c11959 Oct 4, 2022
@riderx
Copy link
Collaborator

riderx commented Oct 4, 2022

Sorry for checking the wrong platform ! thanks for the fix, new version will be publish by CI

@riderx
Copy link
Collaborator

riderx commented Oct 4, 2022

1.1.7 is available https://www.npmjs.com/package/@capgo/capacitor-crisp
do npm i @capgo/capacitor-crisp@latest and npx cap sync to try it :)

@loicparent
Copy link
Author

oh good catch, you want to do to a PR ?

Sorry for my late reply. I see that you've changed the code. Thank you :)

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

No branches or pull requests

2 participants