question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sendBranchEvent callback is not invoked

See original GitHub issue

I’m calling sendBranchEvent in the same way as the example posted here: https://docs.branch.io/apps/cordova-phonegap-ionic/#track-commerce

However, the promise never resolves on Android (I haven’t tested iOS yet). The issue seems to be that the callback was commented out:

https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking-attribution/blob/master/src/android/io/branch/BranchSDK.java#L810

If the callback is not supposed to fire, please update the docs. Actually – the README still uses Branch.sendCommerceEvent, which is deprecated according to the code (https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking-attribution/blob/master/src/index.js#L169).

Additionally, I noticed that the parameter checks for this method (and others) look incorrect (https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking-attribution/blob/master/src/android/io/branch/BranchSDK.java#L148):

// this will never fire! Should be OR rather than AND?
if (args.length() < 1 && args.length() > 2) {
    callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
    return false;
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sebaferrerascommented, Jul 5, 2021

@sequoiaat I can confirm that the callbacks are not invoked when using the sendBranchEvent method.

When running the Ionic 3 Example App, the code should show an alert after calling the sendBranchEvent() method:

BranchStandardEvent() {

  const Branch = window["Branch"];

  Branch
    .getStandardEvents()
    .then(function success(res) {
      var event = res.STANDARD_EVENT_ADD_TO_CART;

      var metadata = {...};

      Branch
        .sendBranchEvent(event, metadata)
        .then(function success(res) {
          alert("Branch Event success " + res);   // <---------- here!
        })
        .catch(function error(err) {
          alert("Branch Event " + err);           // <---------- and here!
      });
    })
    .catch(function error(err) {
      alert("Get Standard Event " + err);
    });
}

But the callbacks are not being executed.

Logs show that the events are being sent properly to Branch’s server so the issue seems to be just that the callbacks are not being called.

Logs: logs.txt

1reaction
echo-branchcommented, Oct 21, 2019

@sebaferreras Adding a ticket for this. The iOS and Android apis are fire and forget. We should have just called the JS back with a success as soon as the event queued to native code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async callback was not invoked within the 5000ms timeout
I am receiving the following error message from Jest, the code does indeed work. Timeout - Async callback was not invoked within the...
Read more >
Model Callbacks - MATLAB & Simulink - MathWorks
This callback is not called during model update. For an example, see Automate Simulation Tasks Using Callbacks. This callback is called for every...
Read more >
window.requestIdleCallback() - Web APIs | MDN
A reference to a function that should be called in the near future, when the event loop is idle. The callback function is...
Read more >
JavaScript Callback Functions – What are Callbacks in JS and ...
This is called asynchronous programming. Callbacks make sure that a function is not going to run before a task is completed but will...
Read more >
Callback is not working! | 3CX Forums
Dear, I configured the callback im my queue, but this working only with internal calls (extension to extension). How to made to working...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found