lmahdi / in-app-purchase-air-ios

Automatically exported from code.google.com/p/in-app-purchase-air-ios
0 stars 0 forks source link

Does this work in CS5 / ActionScript #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm really keen to use this library but all my projects have been developed in 
Flash / AS3.

Can someone describe how we do this using CS5 Actionscript instead of Flex? Is 
there a CS5 sample project somewhere we can use?

Thanks

Leon

Original issue reported on code.google.com by lgcadeb...@googlemail.com on 26 Oct 2011 at 12:40

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Testbed update (2): fixed minor bug when omitting to pass a debug textfield to 
the InAppPurchasesControllerIOS constructor.  Also added optional callbacks.

Original comment by pas...@lisieremedia.com on 12 Jan 2012 at 6:10

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Neil,

If your are using my test bed, you need to pass the products IDs to 
InAppPurchasesControllerIOS constructor, which means you need to modify 
InAppPurchasesTest.as.

- Pascal

Original comment by pas...@lisieremedia.com on 12 Jan 2012 at 4:50

GoogleCodeExporter commented 8 years ago
Thank you Pas for this great example. I am using your test bed to attempt to 
buy a product that I have set up in iTunes connect. I see all my products 
correctly when testing on my iPad2 however when I try to buy a product, I just 
get the following:

> Attempting to buy product 0...
> APP - onUpdate
> App - onUpdate

Then nothing else.

If I click the "Get Transacs" button, I see the details of this transaction but 
it has a state of 2 and a state desc of FAILED.

Any idea why it would fail?

Thanks

Paul

Original comment by mediakit...@gmail.com on 13 Jan 2012 at 4:41

GoogleCodeExporter commented 8 years ago
Sorry Paul,

No idea, what might be going on.  I only made a wrapper around Saumitra's 
sample code, and added a little UI.

It seems like the testbed is functional, but there is something wrong with the 
purchase transaction.  I would assume this has to do with the way in-app 
purchases is set up on iTunes Connect?

- Pascal

Original comment by pas...@lisieremedia.com on 21 Jan 2012 at 10:40

GoogleCodeExporter commented 8 years ago
Thanks Pascal - I resolved the issue. The itunes sandbox was down when I was 
testing but since then has come back and all works very well.

Thanks

Paul

Original comment by mediakit...@gmail.com on 22 Jan 2012 at 6:55

GoogleCodeExporter commented 8 years ago
Can anyone confirm if the login popup box should always appear when I call 
restore transactions.

In my app, when I run it, I check for the existence of a file storing a flag to 
indicate if in app purchase has been purchased or not. If this file does not 
exist, I call the restore purchases function to check if user has previously 
purchased the in app purchase but since then deleted the app from their device.

Hence the first time ever I run the app, the file is obviously not found and it 
therefore calls the restore purchases function. Ideally I do not want to 
display this login box at this point as it is confusing to the user as they 
have no idea why they are being asked to login.

If there is no way to prevent it appearing, I would perhaps be better just not 
calling the restore function and relying on the fact if a user has previously 
purchased the app and tries again, they will not be charged again.

Any advice?

Original comment by mediakit...@gmail.com on 24 Jan 2012 at 3:15

GoogleCodeExporter commented 8 years ago
Hi Paul,

I ran into the same issue.  Unfortunately, restoring transactions always brings 
up the pop-up box.  I think that the app store mandates that the user have the 
ability to restore teansactions, so adding a button to your UI is all you need 
to do.  I wouldn't have the app do the restoring automatically.  This means 
that your app should store all previous succesful purchases into an LSO.  If 
the user erases the app from their device and later reinstall it, it will be up 
to him/her to click on 'restore purchases'.

Pascal

Original comment by pas...@lisieremedia.com on 26 Jan 2012 at 11:05

GoogleCodeExporter commented 8 years ago
Alternatively, you can also run 'restore transactions' once, the first time the 
app is run, and store that fact as a boolean in an LSO, so you don't have to do 
it again.  I personaly prefer to leave it to the user to restore their own 
purchases if they reinstall the app.

Original comment by pas...@lisieremedia.com on 26 Jan 2012 at 11:25

GoogleCodeExporter commented 8 years ago
Thanks Pascal. I have amended my app so it has a button to restore purchases. I 
am storing a flag to remember if they have purchased the in-app purchase. I was 
previously using a shared object to store this flag however after reading the 
following post, I changed it to use the File API. 

http://www.saumitrabhave.com/2011/11/air-ios-solving-apps-must-follow-ios.html

I have however read on another thread that people are not being rejected for 
using shared objects but they may have just been lucky.

My app also stores some user progress data and ideally I need to make this 
accessible to any instance of the app. So if they play on say their iPhone and 
it saves the progress data then later if they play the same game on their iPad 
I would like it to use the progress data from the iPhone. Any idea if this is 
possible?

Original comment by mediakit...@gmail.com on 26 Jan 2012 at 12:10

GoogleCodeExporter commented 8 years ago
To store progress data across devices I would think that you'd have to 
store/retrieve that information from your own web server.

Maybe Apple provides some API to do this on iCloud.  Not sure...

Original comment by pas...@lisieremedia.com on 26 Jan 2012 at 11:55

GoogleCodeExporter commented 8 years ago
Ah ok thanks Pascal. I thought perhaps if I saved the data to the folder that 
is automatically backed up by iCloud that all instances of the app for a 
particular user would automatically download this info. Perhaps this is not the 
case though

Original comment by mediakit...@gmail.com on 27 Jan 2012 at 9:18

GoogleCodeExporter commented 8 years ago
Pascal, I wondered how you are dealing with the scenario where a user is not 
online. I tested another app that included in app purchases and if I try to 
make a purchase when I have my iPad set to Airplane mode, I instantly get a 
popup saying "No internet connection" etc. Unfortunately my app does not do 
this so I am wondering if I need to write some code to test for an internet 
connection and display a popup if none detected . In the other app I tested the 
popup was a standard looking popup - similar to the one that pops up when you 
are asked to login.

Any advice appreciated. 

Original comment by mediakit...@gmail.com on 31 Jan 2012 at 11:44

GoogleCodeExporter commented 8 years ago
When my app launches, after instantiating the iap controller, I immediately do 
a 'finish transactions' (to clear stuff up) followed by a 'get products', and 
only draw the UI menu where the user can make purchases once I receive the 
product list from the store ( AppPurchaseEvent.PRODUCTS_RECEIVED event in 
Saumitra's code OR you can pass a callback to my controller's constructor ).

If the device is not connected, it won't receive the event, until the device is 
connected.  After that, if the device loses its connection, I just leave the 
purchase menu, but if a user tries to make a purchase, they'll get the native 
pop-up.

You could make code in AS to check internet connectivity status at all times.  
I think it's somthing like: NetworkInfo.networkInfo.addEventListener( 
Event.NETWORK_CHANGE ... )

Original comment by pas...@lisieremedia.com on 5 Feb 2012 at 10:45

GoogleCodeExporter commented 8 years ago
Actually, come to think of it, I am not totally sure if the user does get a 
native pop-up if there is no internet connectivity from Saumitra/Apple's API.  
I think it just creates a lingering transaction (which would go in as soon as 
the device's connection gets restored -- unless you do a 'finish transactions' 
before it does).

Original comment by pas...@lisieremedia.com on 5 Feb 2012 at 10:54

GoogleCodeExporter commented 8 years ago
Pascal / Saumitra

Really great stuff what you guys have build here. I still would love to get my 
CS5.5 debugger to work with an on iPhone Ap but I'll besides that - I have a 
few practical questions about iTunes connect.

1) Am I right in thinking that I need an approved Ap before I can test In App 
Purchases? or is there some sort of test mode I can configure somewhere to test 
this out.

2) Pascal's "controllor" refers to: 
"https://sandbox.itunes.apple.com/verifyReceipt" is that the real deal or is 
that some sort of test setup?

Thanks in advance

Leon

Thanks

Leon

Original comment by lgcadeb...@googlemail.com on 9 Feb 2012 at 3:45

GoogleCodeExporter commented 8 years ago
You can set up test users in iTunes connect and test in app purchases before 
your app is approved by Apple. You obviously need to have set up your in app 
purchases in Itunes connect too.

Original comment by p...@pet-owners.co.uk on 9 Feb 2012 at 4:02

GoogleCodeExporter commented 8 years ago
One more thing to be aware of when testing is the sandbox (which is basically 
the test environment used for test users) can go down and give you the 
impression your code is not working. So before hacking into your code try and 
determine if the sandbox server is working. I think there is a URL somewhere 
that will let you test this but I do not have it to hand - perhaps it is the 
link you posted ending in verifyReceipt

Original comment by p...@pet-owners.co.uk on 9 Feb 2012 at 4:05

GoogleCodeExporter commented 8 years ago
Thanks Pascal. I'll try that can you comment on this "sandbox.itunes.apple" 
thing? Is that the same for life or should I change that?

Original comment by lgcadeb...@googlemail.com on 9 Feb 2012 at 4:09

GoogleCodeExporter commented 8 years ago
Sorry one more (VERY STUPID!) question. When I first tried your application 
(which worked find by the way!) I logged in with my normal iTunes account. Do 
you know how I can make the application thing it shouldn't be use that? I've 
logged out in settings, deleted the App, Switched the phone on/off and it still 
remembers.

Original comment by lgcadeb...@googlemail.com on 9 Feb 2012 at 4:11

GoogleCodeExporter commented 8 years ago
Leon - I usually just go to settings on the iPad and on the left hand side 
there is a "store" button. Click that then on the right hand it should say 
Apple ID: xxxxx@xxxx.com

Click on the apple id and it will give you the option to sign out

Original comment by p...@pet-owners.co.uk on 9 Feb 2012 at 4:21

GoogleCodeExporter commented 8 years ago
OK that worked (sorry I knew that was stupid!) - still can't get to my products 
though. I must be doing something else wrong. What I did was:

- Create "test user" in iTunes connect
- Create "Test application" (which Apple has rejected). The bundle ID for this 
application is: com.MYCOMPANY.appurchasetest
- In "Manage in-App purchases" added a product which now has a status of: 
"Ready to submit". The product id for this thing is "10_Coins"
- Then changed your application so it starts with:

private const productIdsOffered:Array = [
                                "com.MYCOMPANY.appurchasetest.10_Coins"
                    ];
- Compiled it with my provisioning file and put it on my iPhone. That all works 
but when I press "Get Products" it shows:

Could not retrieve: product_id = com.MYCOMPANY.appurchasetest.10_Coins

Am I missing a step?

Thanks again for your help

Original comment by lgcadeb...@googlemail.com on 9 Feb 2012 at 4:31

GoogleCodeExporter commented 8 years ago
Try

private const productIdsOffered:Array = ["10_Coins"];

Original comment by p...@pet-owners.co.uk on 9 Feb 2012 at 4:37

GoogleCodeExporter commented 8 years ago
That was part of the problem - thanks. What caught me out (again....) was that 
the <ID> in the XML build file has to be identical to the one registered in 
iTunes Connect. Without that it just won't work.

Thanks for all your help again.

Leon

Original comment by lgcadeb...@googlemail.com on 9 Feb 2012 at 5:51

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hello all, I am creating a game for iOS using FlashDevelop, and now i am about 
to add in-app purchase feature in it. I've downloaded the appPurchase library, 
included it as an external library in "lib" folder of my project, and added the 
extension tag and ID in application.xml...

Tried compiling it, and getting error (It's normal from what i read here, 
right?). Then I got the SWF file of my game, and created a .bat file for the 
SWF packager. first I got an error for the packager, then managed to fix it, 
but another error came. Here's what it said in the packager when I tried to run 
it :

unexpected failure: inputs not set
java.lang.IllegalStateException: inputs not set
        at com.adobe.air.ApplicationPackager.createPackage(ApplicationPackager.j
ava:61)
        at com.adobe.air.ipa.IPAPackager.createPackage(IPAPackager.java:217)
        at com.adobe.air.ADT.parseArgsAndGo(ADT.java:557)
        at com.adobe.air.ADT.run(ADT.java:414)
        at com.adobe.air.ADT.main(ADT.java:464)

What went wrong?I've tried fixing it many times, but no use. is it from the 
java problem, or anything else?

Thanks,

Edi

Original comment by bajajed...@gmail.com on 6 Apr 2012 at 10:37

GoogleCodeExporter commented 8 years ago
Hi

is there any one who is successfully used this in flash sc 5.5 and distribute 
in app store???  

Original comment by devalm...@gmail.com on 11 Jul 2012 at 7:50

GoogleCodeExporter commented 8 years ago
I successfully used this in 2 apps created with Flash CS5.5 and Air 3.2, both 
of which are currently in the app store. However I have since discovered an 
alternative solution from Milkman Games 
(http://www.milkmangames.com/blog/tools/) which is so much easier to implement. 
There is a cost but not a lot and worth every penny!!

Original comment by mediakit...@gmail.com on 11 Jul 2012 at 8:47