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

Java method callApiMethod is not working #6

Open
ianitsky opened this issue Jan 29, 2021 · 0 comments
Open

Java method callApiMethod is not working #6

ianitsky opened this issue Jan 29, 2021 · 0 comments

Comments

@ianitsky
Copy link

I created a new method to call from cordova based on android sdk:

//Android Sdk
HuggyChat huggyChat = HuggyChat.getInstance(this.SDK_ID, YourChatActivity.this).setUpWebView(yourWebView);

// Send message to chat
huggyChat.callApiMethod("sendMessage", "Minha primeira mensagem");
//New Method for cordova
public void callApiMethod(String methodName, String data, CallbackContext callbackContext) {
     try {
         HuggyChat.getInstance().callApiMethod(methodName, data);
         callbackContext.success();
     } catch (Exception e) {
         callbackContext.error(e.getMessage());
     }
}

It's called after chat opened.

But doesnt work. The callApiMethod is receiving the data normally and the instance exists in debug, but it doesn't execute the method.

Example:

window.cordova.plugins.huggychat.openHuggyChat(
  "SKD-KEY",
  "Huggy Chat",
  (success) => {
    console.log('openHuggyChatSuccess', success); //It's logging
    setTimeout(() => {
    window.cordova.plugins.huggychat.callApiMethod('sendMessage', 'Minha primeira mensagem',
      (success) => { 
           console.log('callApiMethodSuccess', success); //It's Logging
      },
      (error) => { console.error('callApiMethodError', error); }
    )
  }, 10000)},
  (error) => { console.error('openHuggyChatError', error); }
);
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