THIS PROJECT IS NO LONGER MAINTEAMED - LINKS CAN BEEN BROKEN
How to implement Project Glbasic StoreKit GlBasic:---> Apple iOS <---
For using InApp Purchases for iOS, there is a lots of configuration that need to been done, but im wont explain it anything, because im thinks it will take for much time. So instead im adding some doc links instead.
1. Setup InApp Purchases in
iTunes Connect:
https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/13_ManagingIn-AppPurchases/ManagingIn-AppPurchases.html (https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/13_ManagingIn-AppPurchases/ManagingIn-AppPurchases.html)
pay attection to Entering Pricing and Availability Information about Product ID, which should uses the AppID and then the product name.
2. In the
MKStoreKit-xcode folder in the project download is that way the x-code project should been implemted correctly (here tested with glbasic version 11.171 only, where the iCade issue was fixed).
3. You can look for more help here:
http://labs.freescapes.org/blog/tutorials/hitchhikers-guide-to-mkstorekit/ (http://labs.freescapes.org/blog/tutorials/hitchhikers-guide-to-mkstorekit/) (etc more document required, but its still under dev).
---> OUYA <---
1. For developing to OUYA, you need your dev key as well the key.cer file. the dev key can been insert in inapp.gbas and the key.cer is need to been put into to assests/Android/key.der. Glbasic does NOT copy that folder automatic (because its outside the Media folder).
2. No PList is required for OUYA, but your need also add the SKU's you using in the OUYA Portal (make sure the sku you using for OUYA is unique, not to been used in other shops).
3. You should uses ANDROIDEXTRAS (https://dl.dropboxusercontent.com/u/3236515/GreedyMouse/AndroidExtras.zip) for game controller and of of course just added inapp support (howover its include in android.gbas as well in this project).
---> Google Play <---
1. First at all, you need to setup your sku, which you can read more about it here: http://developer.android.com/google/play/billing/billing_admin.html - Only managed items is supported right now.
2. You need to insert your APPLICATION KEY (NOT THE DEV ONE) in the InAppConfig_PublicKeys$(). Its a quite long key.
3. Setup your SKU just as you did in the Google Play console in the InAppConfig_SkuNames$() function. The sku names should not use same name as the other (due OpenIAP limit).
4. Implement rest as the functions, just as you would do on OUYA, WINDOWS (which is fake purchases, but nice under test).
---> The Glbasic Project It Self <---
Here is the glbasic project (version 1.0 beta 5):https://www.dropbox.com/s/n7jm2ayc55etyy0/GlbasicStoreKit.zip
Some Notes:- Also
GLB_ON_PAUSE will been sendt when a progress is going (The StoreKit uses callbacks). Here its can checked if INAPP_STATUS$ contain something or not.
-
INAPP_ERROR$ can been outputtet when a error have been happens (like a user cancel).
- If a Purchases have been a succes, then its would been sent to
INAPP_PURCHASE$.
- Only Non Consumable is supported right now (to get thing working).
-
iOS5.0 and up is required. That MKStoreKit does NOT work in 4.3 and below. That will not been changed at all.
-
InAppPurchase_isAvailable() does no longer return 0 or 1, but a hashed value. They are different for different products (but same across all platforms).
- Do a fake product checking from InAppPurchase_isAvailable() to prevent hacking (etc allways return correct) for Android.
Those can been happens anytime in the runtime, so check its in your game loop, so you can progress your purchases.
there is a nice itunes Connect tutorial here:
http://www.glbasic.com/forum/index.php?topic=6711.0
And remember, only Non-consumable can been used by now.
Hi spacefractal thanks for the code, most than for use it, for learn, I like a lot see this Complex Codes, really learning this kind of programming GLBasic turns like a Beast...
Thanks a lot...
:nw: :nw:
yes its not for beginner really and require some configuration one to suit all shops (mainly you need to deal offline as well restoring required by Apple). Howover im do missing a example how to use. That about later.
Howover im have around tried to somewhere use the same functions AppGameKit did in the end, hence im did some comments about thier uses.
On Windows all purchases can been done, so the ui can been tested on that too.
I'm looking if exist such kit on android....
EDIT, will try implement this one:
https://github.com/jlopez/ane-storekit
And also codning OUYA to the provider list, this one supports Amazon Appstore and Google Play. Property the two most important providers.
Admin, fell free to move this thread to Beta Test.
Great stuff and very useful! :good:
Oh wow good job.. if you could make a cross platform IAP lib that'd be amazing. I might be able to stick w/ GLB for a bit longer after all :) Will have to take a deeper look into this at some point.. it opens up a lot of possibilities. Thanks alot!
It's designed to been poosible expanded to other provider and platform. That way I'm interface it's with glbasic functions.
On android there require some security (google play require public key in one java file. but have a idea by a java calls.
So if you can get it to work on iOS, it's should could works on android when done.
Configurations can been a bit pain.
Comon, admin, move it to beta test form :-)
Ps. Greedy Mouse uses that for iOS of course, just uploaded to them, but have a dev realease enabled.
Hi Space, just in case no moderator saw this post and the question about moving it to a different area of the forum, we can use the "report to moderator" button, so it gets faster on their hands. :good:
on Android, its seen OpenIAP is a better way doing inapp. That one supports various Stores (Like Google Play, Amazon Appstore and Samsung Apps), but not OUYA (which would try that later).
Thank you so much spacefractal. I was looking for something like this. :good: :good: :good:
Moved as per request.
im are currectly clean some things up, so its easier to understand what its going, and in a more logical order. Im will release a new beta later this week.
Im are currectly looking and implement OpenIAP to Android, which require some SKU configurations and public keys.
When done im will release the gbas project for easier understand and implement for you.
the code will begin been more complect when im going to implemeted the Android as well OUYA stores as well (which require various keys). here im will integrate that into ANDROIDEXTRAS, which will share the same glbasic api (which need to change a bit). By now this is a start and works fine for iOS (android take some longer time than iOS, which was actuelly very easy due MKStoreKit).
Hopefully im a day in this or next week im will wipe up a little example of its use.
im have just updated the first thread to include OUYA inapp purchases (SDK 4.0 and Android Extras is required, but the gbas project from there is NOT used, but instead using the java calls directly).
So for now its working for iOS 5+ and OUYA.
today im just got Google Play version to work :good:.
Im update this very soon to the first post (edit: just added and also added link to the ANDROID EXTRAS link as well, which got updated as well).
Now im need to add a example how to yse the Project GlBasic Storekit. Its can been a little bit compliced due all those keys and setup. the implementation should been pretty easy.
Howove on Google Play, you can only test it with signed binary.
[ADDITIONAL INFO BEFORE STARTING THE TUTORIAL]
For OUYA IAP you need to have an OUYA developer ID (or UUID). This can be found here - https://devs.ouya.tv/developers
Look under the text that says -
QuoteDeveloper UUID (used for configuring in-app purchases):
It's a series of alphanumeric characters in the format - XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (8-4-4-4-12 chars). You need to place this into the inapp.gbas file (see (2b) later).
You will also need to attach the following .gbas files to your main project -
- AndroidExtras.gbas
- inapp.bgas
- hashnumber.gbas
- Funcs_General.gbas
These are all found within SpaceFractal's/FiveSprites' Android Extras folders. Ensure that you have the latest updates of all files within.
You will also need a another Developer
Application Signed Key - you get this from the OUYA dev portal when you create a
new GAME (Edit: NOT Product). I don't know if it's my browser (FF) or what but clicking the "download" Signing Key button doesn't download the key for me - I had to right click and Save Target. This will then create a nice little certificate called "key.der" you need that for later.
OK. Now you have everything you need to make a start. You do have an OUYA and a GLB program that works on Android/BlueStacks right? Well, now you can begin... :)
This above have wrote by Ian, before my Tutorial to explain extra ting.
Im have still not wiped up a example and have first time in the next week. So im thinks im will try to explain how the
OUYA shop work, which is a good start.
So here we go:Im do have to say its can been a quite tricks, due inapp purchases uses callbacks and might first checked correctly after a little while (its asyncron).
1a. For all shops, you need to setup your sku, so the shops known which id people tryting to get. For OUYA, you doing that for this url (after login):
https://devs.ouya.tv/developers/products*NOTE* The SKU will take the form of
"com.yourname.gametitle" - this information is found in the AndroidManifest.xml file when you create your Android app. The product name MUST match this, otherwise the OUYA store will not accept any upload.
1b. Here you setup your product and only
Entitlement type product is supported. Price there can been changed, which will reflect for your game (and you dont get changed for testing your own inapps).
1c. For config skus for glbasic, its done in
InAppConfig_SkuNames$ function in inapp.gbas. that sku might been named different (which is required for all Android shops), which is checked by IF iID$="0" OR iID$="internal.sku" line (so im only need to uses one sku name internal).
2a. Tthere is
Signing Key for each game, which is required too. That need to been put in
distribute\Android\assets\Keys, and NOT in the Media folder.
2b. There is a dev key as well. That dev key need to been put in the
InAppConfig_PublicKeys$ in the
com.ouya.shop line (in the RETURN statement).
2c. You need to add a line to AndroidManifest.xml, which is
<uses-permission android:name="com.android.vending.BILLING" />. Without that, you cant uses the paymant screen.
That was the setup stuff, which can take a quite of time to understand.
Here is how the various functions should been used:3. You need put a
InAppPurchase_Update() in every loop. That control anything when something happens and need to checks callbacks under purchases.
4. To check if the user have purchased a product, you can uses a
InAppPurchase_isAvailable$("internal.sku"). You dont need to do a internal variable, its should works offline too (but not checked). On that function, you should also do a fake purchase as well, if java have been temped.
5. To check a price of a purchase, do a
InAppPurchase_Price$("internal.sku") name (you can also check shop online at
InAppPurchase_isOnline()). its might take a while, due this is a asyncron function and uses a callback.
6. When the user press on the Purchase button, you will send a
InAppPurchase_Activate("internal.sku"). That should send the paymant box to the screen.
7. If the purchases is a succes, you will see the sku name in INAPP_PURCHASE$. Its will contain a string when users purchases is a succes.
8. If something failed, you will see INAPP_ERROR$.
Please Note:A. When user is on the purchase screen, your app would been sent a
GLB_ON_PAUSE, and
GLB_ON_RESUME when the screen is gone. That because the payment screen is using its own intent (which is same sort of a new Window on Windows). Here you might need to make sure the pause dont popup here when that happens. That is up to you to implemented, and is not checked by storekit.
On Android, restore purchases is NOT required, that is for iOS only. Apple will reject if you not doing that. This is what
InAppPurchase_Restore() do. When succes a INAPP_PURCHASE$="restored" (or a INAPP_ERROR$ if failed) would been set and then recheck for items using InAppPurchase_isAvailable$().
We need a straightforward guide for Android Extras, or a one click install :) Also concerning this StoreKit, you mention OUYA a lot, what is the procedure for GooglePlay Store?
Pretty similar for doing the OUYA. Its pretty much only sku details as well the key setup that is different, rest for implemented is the same thing. The Java api auto detect the correct shop, so its only sku and key setup, that is different.
1. Here you setup the sku details in google Console / Your App Title / In-app Products instead. Here its only Managed Product type product its supports. Make sure the sku id which is the unique id for your items is not the same as on OUYA shop (which is why you uses a "internal sku" ingame). its could been com.spacefractal.greedymouse.gplay_premiumkey example.
2. There is a license key for each app which is in Google Console / Your App Title / Services & Apis. That key is to been put in InAppConfig_PublicKeys$() function for "com.google.play" line. Its a pretty long key.
Rest implentation is pretty much the same as for OUYA. The only different is the testing part is much easier on ouya. Here you can uses own test account for testing inapps purchases, whole on Google Play, you need external accounts for doing that, and you cant purchases your own product (which could been handy for testing)
PS. The SDK Upgrade as well AndroidExtras is included Java Inapps apis, but did not include the example. so if you have installed that, then you should could uses that download from the first post (the inapp.gbas file).
Thank you for all this :D
Would be awesome if you could expand a bit the information about OUYA :)
What help do you need with the OUYA storekit?
I did not understand how to add IAP and Controller support to an existing GLBasic project :(
For controllers and IAP you will need to add a number of extra files to your project. These files are -
- AnroidExtras.gbas
- inapp.gbas
- Funcs_General.gbas
- hashnumber.gbas
Go into the jump-bar on the right of the GLBasic IDE and click "files", right click on "sources" and "add file" - you can find these files in the Android Extras/IAP folders. Also goto "Source code file" in "File" and "Open" the selected files. Make sure you use "Save all opened files" - this should ensure that your files all stay together and help to compile without problem.
The controllers only need the AndroidExtras, but the IAP needs everything else.
For controllers you must ensure that you use something like this -
WHILE TRUE
// Analogues D-Pad
IF (GameControllers("Up", 0)>600 OR GameControllers("PadL_Up", 0)) THEN ...
IF (GameControllers("Down", 0)>600 OR GameControllers("PadL_Down", 0)) THEN ...
IF (GameControllers("Left", 0)>600 OR GameControllers("PadL_Up_Left", 0)) THEN ...
IF (GameControllers("Right", 0)>600 OR GameControllers("PadL_Right", 0)) THEN ...
SHOWSCREEN
GameControllers("Update")
WEND
You need to ensure that the analogues have a value of 600+ as otherwise they are too sensitive.
hope that helps for now.
IAP takes a bit more to work out, but you'll need the controllers to work first...
Thank you Ian Prince for your help! really useful :D
I may be a "prince" among men ;) (LOL), but my name is Price :D
Glad it helped. BTW.
yes inapp take quite more work with the sku setup and details. Now Ian also got the thing to work too (and im faced also my own bugs too, hehe later). Its should been easier now.
In the recent beta of Storekit....
inapp.gbas have been splitted to inapp_config.gbas and inapp_functions.gbas. That will been easier for me to update to functions without reconfig again.
PS. You could do anything >600 for both analog and digital. On some joypads those mightbeen swapped. But no issue on OUYA doing that.
We appreciate you publish your work to serve the community. :nw:
Are you considering implementing Android ads in StoreKit?.
I'm have not a plan for ads yet. More important is expandsion support for google play and skillz for iOS end of this month.
can somebody move this in a better forum than a beta? Even its still a better, its property never go out of beta in the end really. Im have not plans to add consumable items support right now.
Where do you want it? Bonus/Code Snippets or GLBasic - English?
this build is still official, so bonus forum is not required for those with 100+ posts, so either in Code Snippets or Inline / 3rd party is best me thinks.