cordova-ionic-phonegap-branch-deep-linking-attribution icon indicating copy to clipboard operation
cordova-ionic-phonegap-branch-deep-linking-attribution copied to clipboard

sendBranchEvent callback is not invoked

Open phiferd opened this issue 5 years ago • 9 comments

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

phiferd avatar May 21 '19 04:05 phiferd

Hi @phiferd

Did you find any solution for this? Is anyone fixing this issue?

Additionally i tried firing the event from Android but it never reaches the branch dashboard. I have tested in iOS and it is getting tracked. Following is the snippet of my code:

Branch.initSession(event).then(function success(res) { console.log("initSession Success " + res); Branch.disableTracking(false).then(function success(res) { console.log("disableTracking Success " + JSON.stringify(res)); Branch.setCookieBasedMatching("xyz.app.link").then(function success(res) { console.log("setCookieBasedMatching Success " + JSON.stringify(res)); Branch.setIdentity("999999999").then(function (res) { // For Test console.log('setIdentity Success: ' + JSON.stringify(res)); Branch.getStandardEvents().then(function success(res) { console.log('getStandardEvents Success' + JSON.stringify(res)); var event = res.STANDARD_EVENT_COMPLETE_REGISTRATION; Branch.sendBranchEvent(event).then(function success(res) { console.log("Event Success " + JSON.stringify(res)); }).catch(function error(err) { console.log("Event Error " + err); }); }).catch(function (err) { console.log('getStandardEvents Error: ' + JSON.stringify(err.message)); }) }).catch(function (err) { console.log('setIdentity Error: ' + JSON.stringify(err.message)); }); }).catch(function error(err) { console.log("setCookieBasedMatching Error " + err); }); }).catch(function error(err) { console.log("disableTracking Error " + err); }); }).catch(function error(err) { console.log("initSession Error " + err);});`

Anything I could be doing wrong?

ranaavneet89 avatar Jul 12 '19 10:07 ranaavneet89

@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

sebaferreras avatar Oct 03 '19 12:10 sebaferreras

Yes this causes issues in our app as well.

ghost avatar Oct 07 '19 13:10 ghost

I can repro this too, seeing the same thing...

mehalick avatar Oct 07 '19 13:10 mehalick

We have the same issue too

samibn avatar Oct 08 '19 04:10 samibn

Same here :frowning_face:

kedzior-io avatar Oct 08 '19 06:10 kedzior-io

@echo-branch, do you know if there's a ticket already created for this issue? Thanks 🙂

sebaferreras avatar Oct 21 '19 06:10 sebaferreras

@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.

echo-branch avatar Oct 21 '19 20:10 echo-branch

@echo-branch is there any update on this issue? Thanks.

sebaferreras avatar Apr 30 '23 11:04 sebaferreras