cordova-ionic-phonegap-branch-deep-linking-attribution
cordova-ionic-phonegap-branch-deep-linking-attribution copied to clipboard
sendBranchEvent callback is not invoked
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;
}
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?
@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
Yes this causes issues in our app as well.
I can repro this too, seeing the same thing...
We have the same issue too
Same here :frowning_face:
@echo-branch, do you know if there's a ticket already created for this issue? Thanks 🙂
@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 is there any update on this issue? Thanks.