heroiclabs / nakama-defold

Defold client for Nakama server.
https://heroiclabs.com
Apache License 2.0
75 stars 12 forks source link

SDK Updates #28

Closed novabyte closed 3 years ago

novabyte commented 3 years ago

We need to investigate what the IAP support in Defold engine looks like as well as introduce the new session refresh APIs to the client object.

britzl commented 3 years ago

In-App Purchases for iOS, Android (Google+Amazon) and Facebook are handled in this extension:

https://defold.com/extension-iap/

Basic API is:

iap.set_listener(fn)
iap.list(product_ids, fn)
iap.buy()
iap.finish(receipt)

What do you need specifically? Is this for receipt validation?

introduce the new session refresh APIs to the client object

Could you tell me more about this?


I can pick up this task later this week or beginning of next.

novabyte commented 3 years ago

What do you need specifically? Is this for receipt validation?

Yep its for receipt validation. There's three new endpoints which are used directly for receipt validation with Apple, Google, and Huawei. In the .NET client they were added in this pull request. It's a method each to take a receipt from the purchase provider and pass it to the server which validates it and stores it to prevent replay attacks.

Could you tell me more about this?

Sure, we also recently added refresh tokens to the server which can be used to obtain a new session token. This reduces the need to reauthenticate players (though the same pattern as normal still applies if developers use social sign-in options like Apple Sign-in and Google Play). We added it to the .NET client in this pull request.

The overall code for session refresh added both a way to configure the client object to auto-refresh a session and also to add the API function to manually refresh a session with the server.

I think the code generator in the repo should do most of the manual work to build the request and inputs. 🤞

Thanks @britzl 🙏

britzl commented 3 years ago

FYI Starting work on this now.

novabyte commented 3 years ago

Thanks @britzl 🙏

britzl commented 3 years ago

I ran the code generator with the latest API definitions and there was indeed a number of new IAP receipt functions.

I also noticed some changes to linking of Steam accounts.

And the generated code for the "/v2/friend" endpoint has some new arguments (I don't see how the functions could have worked before).

Finally there was also a new "/v2/session/logout" endpoint.

britzl commented 3 years ago

PR with the changes: https://github.com/heroiclabs/nakama-defold/pull/29

britzl commented 3 years ago

For the IAP purchase validation we need to add some documentation about which Defold extension to include when using In-App Purchase. I don't see any IAP related docs yet though (https://heroiclabs.com/docs/index.html).

britzl commented 3 years ago

Oh, here it is: https://heroiclabs.com/docs/iap-validation/

britzl commented 3 years ago

Commit to my nakama-docs branch with IAP validation for Defold:

https://github.com/britzl/nakama-docs/commit/1f212c47f973e308cf21dad0ebdf87556f0c1686