godotengine / godot-google-play-billing

Godot Android plugin for the Google Play Billing library
MIT License
138 stars 39 forks source link

Signals not firing properly #47

Open Chrompower opened 1 year ago

Chrompower commented 1 year ago

Hello

when using:

func _ready():
    if Engine.has_singleton("GodotGooglePlayBilling"):
        payment = Engine.get_singleton("GodotGooglePlayBilling")
        payment.connect("connected", self, "_on_connected") # No params
        payment.startConnection()

func _on_connected():
    print("Connected with Google Play")

The connected signal gets fired if there is no active internet connection. The print command always gets executed. I do not trigger the _on_connected() func anywhere manually. I thought that this signal is supposed to be used to check if there is a connection established to the Google servers. According to the Godot Docs you can also check the status with payment.isReady(), but it always returns true. On the other hand, the disconnected signal ("_on_disconnected") never gets fired.

Am I doing something wrong, or missunderstanding something?

I would appreciate any help!

NianoTT commented 1 year ago

I thought that this signal is supposed to be used to check if there is a connection established to the Google servers.

It checks for the connection to Play Services (in this case Play Store) which runs locally - so yes, this does not require internet connection at all.

Things like IAP information is also cached locally so querySkuDetails and such will work. The purchase itself will fail however, the user will be notified within the Google Overlay - after the purchase process started - that they need an internet connection.

Chrompower commented 1 year ago

Thank you very much Niano. I didn't know that.

I have an additional question: Do you have any idea why the sku_details_query_completed signal never gets fired?

I have connected the signals with:

payment.connect("sku_details_query_completed", self, "_on_sku_details_query_completed")

I am starting an SKU-detail-query with:

func _on_connected():
    payment.querySkuDetails(["testsku6"], "inapp") 
    print ("Query SKU details")

The print command gets executed. Then I have this function:

func _on_sku_details_query_completed(sku_details):
    for available_sku in sku_details:
        print("available sku = ", available_sku)
    print ("SKU Query successful")

Here, nothing gets printed / executed. I have also added the _on_sku_details_query_error signals, but they also don't fire. I thought that the _on_sku_details_query_completed signal should get fired after the query was successful. Am I (again) misunderstanding something?

Thanks in advance!

NianoTT commented 1 year ago

If you are using 2.0-rc1 (which I guess you are or you would not be able to upload it since 1.x isn't accepted by google), the signals have been renamed - now its "product_details_query_completed" and "product_details_query_error"

There are a few more changes in the return dictionaries, you can look at the source of #36 for more details. Sadly the docs are not updated as currently nobody maintains this repo.

Chrompower commented 1 year ago

Thanks again Niano.

Really unfortunate that nobody maintains this repo. I think IAP are very important if you want to earn money with your (mobile) games. I have only basic programming skills – so I cannot help with it (yet) :-(

kyadalu1 commented 6 months ago

Try this