Closed Deeeej closed 8 years ago
Did you register any listeners to the "refreshed" event? If so you should checked them out (unit tests?)
Did you try enabling maximum verbosity in the plugin (see API for that)?
The fact that err
is null is probably a mistake in the plugin though.
Hi, thanks for the feedback.
No, we havent attached any listeners to the 'refreshed' event. Out of interest, how would you do this as the documentation seems to suggest there is no way of doing this with the .when() syntax.
We call store.refresh() and get the error, heres the debug output, below.
The strange thing is, if we are not doing anything other than calling store.refresh() after registering the product, under what conditions would this error fire?
[store.js] WARNING: A callback in 'refreshed' failed with an exception. InAppBilling[js]: load ["productxyz"] InAppBilling[js]: setup ok [store.js] DEBUG: queries !! 'refreshed' [store.js] DEBUG: store.trigger -> triggering action refreshed [store.js] DEBUG: queries ++ 'productxyz initiated' [store.js] DEBUG: queries ++ 'productxyz requested' [store.js] DEBUG: queries ++ 'productxyz error' [store.js] DEBUG: queries ++ 'productxyz unverified' [store.js] DEBUG: queries ++ 'productxyz verified' [store.js] DEBUG: store.queries !! 'consumable updated'09:29 [store.js] DEBUG: queries ++ 'productxyz cancelled' [store.js] DEBUG: store.queries !! 'productxyz updated' [store.js] DEBUG: store.queries !! 'updated' [store.js] DEBUG: queries ++ 'productxyz approved' [store.js] DEBUG: store.queries !! 'consumable registered' [store.js] DEBUG: store.queries !! 'registered
Listening to the refreshed
event isn't documented, but it's possible (even though it's an internal event that you shouldn't rely on).
Logs don't really show anything interesting. The exception occurs very early apparently. There's nothing before the WARNING
line? After a short analysis, it seems like the error is triggered from ./src/js/queries.js. So I would expect to see the "queries !! 'refreshed'"
DEBUG
line before this WARNING
..
Unless I have misunderstood, that line is there in the above stack trace.
From the further debugging (another 8 hours today) it appears to be an issue with the actual call to the following line: cordova.exec(success, errorCb(fail), "InAppBillingPlugin", "init", [ skus ]); [780] of android-store.
Am I right in assuming that if this line fails, it will cause the 'A callback in 'refreshed' failed with an exception.' error messsage?
Alright... This could mean that there was a problem with the installation of the plugin. This line is cordova's function used to call a native android method. It's kind of strange that it fails with a "null" exception, that doesn't give much information.
You could try reinstalling the plugin. Make sure the billing key is well configured. If you can breakpoint and trace further down that could be helpful as well.
Thank you for your continued help, it looks like we have solved the issue. For completeness here is how we solved the issue.
We were using the JQuery .ready() event instead of the document.addEventListener("deviceready", function(){onDeviceReady();}, false); event. Switching over solved the issue immediately. This seems like a real rookie mistake, but the errors we were seeing, plus the other behaviour (described below) made it really tricky to diagnose.
What is is interesting to observe is that other plugins were able to successfully call the .exec() method to execute their behaviour, in fact the purchase plugin was the only one that failed (I tested them all, we have other plugins like Activity Indicator, Ionic Keyboard). The issue was not consistent and so it was difficult to find the source of the issue (i.e. if one call to .exec() works, why doesnt another?).
I guess if nothing else, we (and perhaps someone else in the future) has learnt that getting the error message - 'A callback in 'refreshed' failed with an exception' after you call store.refresh(), is almost certainly caused by the .exec() method not being available, and probably thus caused by failure to wait for the deviceready event.
Thank you for your help, its really appreciated. Is the team sponsored or is there a place one can submit donations?
Thanks for the follow-up.
It isn't consistent because it is a race condition. If the native side of the plugin is ready before your JS, then it's a "transparent" bug. If not, it's gonna fail. Probably the other plugins are lighter, so they require less time to be fully loaded by cordova.
Anyway, waiting for "deviceready" is the way to go with cordova, always!
I wonder if it's possible, from within the plugin, to check that the "deviceready" event has effectively been dispatched when "refresh" is first called. That should allow to trigger a more insightful exception.
I am not sponsored. Donation to are welcome, thanks! paypal: donate@ios-software.com
I'm also working on opening a paid server-side in-app purchase management service (receipt validation, subscription management, etc.). The goal is for simple use cases (90% of people) to remove the need for a server altogether, for more advanced use cases to provide a unified REST API for the management purchases (iTunes, Play, Stripe), to be called from your own server without dealing with each platform's specifics. If that could be of interest to you, let me know.
I am using Monaca, an online IDE/environment to build an app.
I get an error 'A callback in 'refreshed' failed with an exception'. It seems as though there is no way to debug this error message. The 'err' object is null so there is no further information.
How can we trace down the issue (its been about 4 weeks of attempting to find a solution). We are using android-store.js. It seems like it is something fundamental. We built a release version of the apk and deployed via google play beta channel, we also tried just installing locally via usb. Is it something to do with the application not being live in production yet?
Any help greatly appreciated.