HaxeObject callback on android returns null

On android I am attempting to use extensions that send data back to Haxe.

The extension from the java side seem to be working correctly. However on the haxe side, the arguments are always null.

I am using extension-iap and openfl-gpg. Both of which work correctly on the java side.

I debug my application in intellij. (java code). and have breakpoints where the HaxeObject has a callback to the Haxe code, using callBack.call and the arguments are fine. In the haxe side, i print out the arguments and they are always null.

Example:
Java:

InAppPurchase.callback.call("onStarted", new Object[]{"Success"});

Haxe:

public function onStarted (response:Array<Dynamic>):Void {
		trace("Variable: " + response + ":response");
}

The result is null.

I am using Haxe 3.2.0 with the newest (haxelib) versions of openfl, lime etc.

I am on Android 5.1

I have not attempted to revert my haxe version, could this be an issue with 3.2.0?

Are you sure you’re using the API correctly from the Java side?

From what I’m seeing in the github repo for extension-iap InAppPurchase Class the callback property is private (and of type HaxeObject – a class defintion I can’t seem to find).

It appears you have to call a static initialize method InAppPurchase.initialize() with a public key and a callback method.

I am using the plugin unchanged.

I initialize it in the Haxe code, and debugged it, using intellij, and just put breakpoints in the java code. I did not modify any java code. (although I am a java developer by trade)

IAP.initialize(LICENSE_KEY);

The java code is working fine, I have a valid key, and it works correctly with the google servers. It is when it tries to send the success back to the java code, is where the problem lies. It comes back to haxe as null.

This is also the same problem with the Google play services plugin, the haxe to java works fine, but when it tries to send the success message back is when it has the issue.

The source code for the HaxeObject is in the Lime repository, and the callbacks pretty much just map to native code.

Again, based on this class:

InAppPurchase.java

it doesn’t appear that you can do the following (from your example) from the Java side:

The callback property is declared as private (and incidentally set to null) in InAppPurchase.java.

im sorry i am not calling that directly. that is the code that is being called from the the plugin.

i have a breakpoint on that line. that function gets called (from within the plugin). after that it goes through lime code, then back to haxe. and by the time that gets back to haxe it looses the parameter.

all of the code is within the plugin. i did not change the plugin. the broken code is within the plugin. that is not my code.

sorry for the confusion

it executes this line:

then goes to this line

the success message gets lost, response is null.

Ah…I see what you’re getting at now. Not sure if this will make a difference but you can try changing the type of the response parameter from Array<Dynamic> to Dynamic in the onStarted() method and see if your trace statements give you back something you can evaluate.

You could also try passing a simpler type (int, string, etc)

on the google play services plugin, the methods expect an integer, and that is just converted to its null equivalent of 0

but just reverted to haxe 3.1.3 and it seems to work fine now.