Skip to content

Java method callApiMethod is not working #1

Description

@ianitsky

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); }
);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions