• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

InApp purchase really basic question

Participant ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

Hi there,

I'm setting up inapp purchasing for the first time and have got a really basic question :-

After a purchase (via an ANE) do you normally save a flag somewhere to indicate that a particular item has been purchased and then check this flag at startup ? i.e. you only go near the actual purchase ANE when buying/restoring.

Aaaand assuming this is the case where do you normally save the flag ?

I would normally use a SharedObject - but there is a bug floating around the place whereby in certain conditions there is a problem flushing the SharedObject.

(see http://forums.adobe.com/message/6142146#6142146 and https://bugbase.adobe.com/index.cfm?event=bug&id=3711301).

Many thanks !

TOPICS
Development

Views

977

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

Yes you would use a sharedobject, and for the moment you can deal with the writing when storage is low problem by enabling the purchased features in those cases. That does mean that a clever user could fill up their device and then get your paid for features for free, but that may be better than not letting them have features that they have already paid for.

The other way to handle it is to put up a message saying that they need to clear some space, but even that sounds like it’s your app that is causing the problem.

BTW< it’s not just flushing sharedobjects that are the problem, you can’t read an existing sharedobject, and you can’t write other kinds of files.

Here’s the bug report, if you want to go and vote for it:

https://bugbase.adobe.com/index.cfm?event=bug&id=3711301

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

Thanks so much Colin. I hadn't realised that there was a problem on reading ... or on other kinds of files. I've voted for the bug (a little while ago) - it seems as though there may be some other combination of factors involved beyond the amount of storage as the guys seem to have problems recreating it. Looks like it's all gone a bit quiet on the bug report - is that normal ?

So you'd try a read (check if they've bought the IAPs) and then a flush of the shared object when the app starts and try and catch the error ? And if the error is thrown, play safe and allow access to any restricted content.

It sounds like the best work around - as it's probably better that way than annoying some user who'd completed an IAP, but is unable to use it due to storage problems.

One other thing ... any preference for Milkman games vs Distriqt ??? Both look pretty solid - toss a coin ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

Yes, to what you said about the approach with sharedobjects.

I’m using Milkman for Google and Apple in-app purchasing. I didn’t know about the Disriqt ANEs until later, when I was trying to figure out local notifications. I have those too now, but no particular reason to change away from the Milkman one. I also use Milkman’s GoViral ANE.

If you don’t own any ANEs, and Distriqt have what you need, then you might as well go with them. They are extremely responsive when you send them emails.

Note that whichever one you use, for Amazon you will have to use the Amazon in-app ANE.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

Thanks again Colin for this (+extra Amazon info) and all you do in the AIR/Flash community - most appreciated !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

Do either of the milkman or distriqt in-app ANE's handle downloading of content from the Apple servers?  I'm not sure if anyone is doing that with an AIR app but it seems like getting Apple to host all additional content would be a good thing to take advantage of.  I just haven't been able to find an ANE that does it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

Not sure about the Distriqt one, but the Milkman Games one does have sample code for how to use the Apple hosted content. That part of the docs starts with:

"This is an an advanced user feature.”

The code looks tricky enough that you might think about having the content in the app, and use the in-app purchase to enable the content. That’s how I’ve done things so far.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

Unfortunately the purchases are too large to embed in the default app (several hundred mb each of video and lots of them) so they have to be downloaded.  I started building my own ANE to handle it but it is a bit fiddly so I was just wondering if there was a nice and easy off the shelf solution.  I guess I might as well just take the pain and finish it off.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2014 Apr 16, 2014

Copy link to clipboard

Copied

In-app purchasing is quite complex, you may as well use the Milkman Games one, it handles all the tricky things for you, and gives you sample code to follow.

Here’s some of the documentation, to give you a sense of what’s involved:

(Optional) Handling Apple-Hosted Downloadable Content

This is an an advanced user feature. Before implementing downloads of Apple-hosted content, note that:

• iOS 6 or higher is required. If you support iOS 4 or 5, you'll need an alternate strategy for hosting.

• You must create and upload the downloadable content using Xcode 4+, with the “In-App Purchase Content” product template. The Bundle Identifier needs to match that of the corresponding In-App Product in iTunes Connect. Upload it by choosing Product>Archive from the XCode menu.

• You should be familiar with the flash.filesystem.File API and the SecurityDomain restrictions that apply to iOS file management in Adobe AIR.

21. Optionally, Apple will host downloadable files for non-consumable items for you, if your app runs on iOS 6 or higher. You can determine if the application is capable of downloading Apple-Hosted content at runtime by using the StoreKit.storeKit.isHostedContentAvailable() method. If it returns false, the device is running an older version of iOS and no downloading will occur.

If it returns true, you can add listeners for the three download events dispatched by the extension:

if(!StoreKit.storeKit.isHostedContentAvailable())

{

trace("this device is not capable of downloading apple-hosted content.");

}

else {

StoreKit.storeKit.addEventListener(StoreKitEvent.DOWNLOAD_UPDATED,

onDownloadUpdated);

StoreKit.storeKit.addEventListener(StoreKitEvent.DOWNLOAD_FINISHED,

onDownloadFinished);

StoreKit.storeKit.addEventListener(StoreKitErrorEvent.DOWNLOAD_FAILED,

onDownloadFailed);

}

22. After a successful purchase of a non-consumable item that includes Apple-hosted downloadable content, the extension will automatically begin the download of the package from Apple's server. As the download progresses, StoreKitEvent.DOWNLOAD_UPDATED events will be periodically dispatched, indicating the progress of the download:

function onDownloadUpdated(e:StoreKitEvent):void

{

trace("downloading item: "+e.productId);

// e.downloadProgress is a 0-1.0 scale

trace("percent complete:"+(e.downloadProgress*100));

trace("seconds remaining:"+e.downloadTimeRemaining);

trace("content version:"+e.downloadVersion);

}

23.Whenthedownloadiscompleted,StoreKitEvent.DOWNLOAD_FINISHEDisdispatched. Theextension will automatically unpack the downloaded content into a subdirectory of your application's local storage path, and provide the location of the downloaded content in the downloadPath property of the event. You may then use the flash.filesystem.File object to access the files and process them in your app, or move them to a new location. In the example below, we look through the download directory and load any PNG files found on to the stage:

import flash.display.Loader;

import flash.filesystem.File;

import flash.system.ApplicationDomain;

import flash.system.LoaderContext;

import flash.system.SecurityDomain;

// dispatched when a download has finished

function onDownloadUpdated(e:StoreKitEvent):void

{

trace("finished downloading:"+e.productId);

var downloadDirectory:File=new File(e.downloadPath);

if (downloadDirectory.exists)

{

var contents:Array=theStuff.getDirectoryListing();

for each(var file:File in contents)

{

if (file.extension=="png")

{

var context:LoaderContext=new LoaderContext(true,

ApplicationDomain.currentDomain);

var loader:Loader=new Loader();

loader.load(new URLRequest(file.url),context);

} }

}

stage.addChild(loader);

}

24. You must also add an event listener for StoreKitErrorEvent.DOWNLOAD_FAILED, which will be dispatched if an error occurs with the download. You should be sure to include this listener to avoid errors halting your program:

// listen for ERROR response during a download

StoreKit.storeKit.addEventListener(StoreKitErrorEvent.DOWNLOAD_FAILED,

onDownloadFailed);

function onDownloadFailed(e:StoreKitErrorEvent):void

{

}

trace("something went wrong with the download: "+e.text);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 17, 2014 Apr 17, 2014

Copy link to clipboard

Copied

Thanks for the info.  Because of the size of the downloads I need users to be able to manage their downloads individually (e.g. buy something, download it, uninstall it, download it again later etc) so I will need to check with Milkman if their ANE allows that level of control (rather than just making sure everything you have purchased is downloaded)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 08, 2014 May 08, 2014

Copy link to clipboard

Copied

LATEST

Hi,

Our extension (distriqt) doesn't provide this functionality at the moment. However we are always looking to add features to our extensions so if you want us to look into it feel free to add it as a suggestion to our support site: http://distriqt.uservoice.com

Cheers

air native extensions // https://airnativeextensions.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines