zendesk / react-native-sunshine-conversations

React Native wrapper for Smooch.io
MIT License
36 stars 26 forks source link

init in javascript rather than native #56

Closed benadamstyles closed 6 years ago

benadamstyles commented 6 years ago

Hi, I'm having this issue: https://github.com/smooch/smooch-ios/issues/185

The solution is apparently to wait for init to complete before calling login, but currently this is not possible in react-native-smooch because init is called in the native realm and login is called in javascript – there is no way that I can find to know in js whether init has completed successfully. I'm ready to submit a PR adding an init method callable from js but before I do I want to make sure that it will be accepted? There aren't any security issues with passing the appId from js?

mspensieri commented 6 years ago

Which version of smooch-ios are you using? This issue was supposed to have been fixed in v6.6.1. You should now be able to correctly call login before init completes, it just has to have been called first

benadamstyles commented 6 years ago

My Podfile.lock says 6.6.1. Ok, so maybe I'm having a different issue? I create a user in smooch v5 and send some messages, I update my app to use v6, and then the message thread is empty and I cannot send any messages. The issue sounds very similar to https://github.com/smooch/smooch-ios/issues/185

benadamstyles commented 6 years ago

I'm going to close this for now until I can investigate further, thanks for your help.

benadamstyles commented 6 years ago

@mspensieri A quick question: can we assume that if smooch.getUserId() (i.e. [SKTUser currentUser].userId) returns a user id string, that user is logged in and authorized to send messages? Or is it possible that the [SKTUser currentUser].userId exists but the user has become unauthorized for some reason or other?

mspensieri commented 6 years ago

There are some situations where a user can have a userId and yet still have invalid authorization. For example, if your secret key was revoked since the user logged in, or if you are generating JWTs with an expiry time which has since lapsed.

I believe you can tell the result of the login call by reacting to the promise that is returned by smooch.login()

benadamstyles commented 6 years ago

@mspensieri Thanks for your help.