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

Channel getMessagesCount causes app to crash #37

Open
simonasdev opened this issue Oct 14, 2017 · 1 comment
Open

Channel getMessagesCount causes app to crash #37

simonasdev opened this issue Oct 14, 2017 · 1 comment

Comments

@simonasdev
Copy link

Hello,
In onSuccess calback for getMessagesCount method in RCTTwilioChatChannels.java, Long argument is being passed to promise.resolve, which, as far as I know, can't be done because react native doesn't implement conversion from Java Long to Javascript Number. The backtrace for the exception is as follows:

FATAL EXCEPTION: mqt_native_modules
Process: com.medcall, PID: 8210
java.lang.RuntimeException: Cannot convert argument of type class java.lang.Long
   at com.facebook.react.bridge.Arguments.fromJavaArgs(Arguments.java:57)
   at com.facebook.react.bridge.CallbackImpl.invoke(CallbackImpl.java:36)
   at com.facebook.react.bridge.PromiseImpl.resolve(PromiseImpl.java:32)
   at com.bradbumbalough.RCTTwilioChat.RCTTwilioChatChannels$16$1.onSuccess(RCTTwilioChatChannels.java:505)
   at com.bradbumbalough.RCTTwilioChat.RCTTwilioChatChannels$16$1.onSuccess(RCTTwilioChatChannels.java:495)
   at com.twilio.chat.internal.CallbackListenerForwarder$1.run(CallbackListenerForwarder.java:31)
   at android.os.Handler.handleCallback(Handler.java:751)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:154)
   at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
   at java.lang.Thread.run(Thread.java:761)

I've found, that it is suggested to use either 64bit double, or 53bit int (source: facebook/react-native#9685)
Can anyone give suggestion how it should be implemented?

@simonasdev
Copy link
Author

If anyone is looking for a quick hack to get the messages count, you can fetch the latest message with getMessages(1) and use the index property and increment it by 1. Note that this will probably only work if there are no deleted messages.

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

1 participant