Hello,
I’m using the InappBilling ANE from Distriqt. One feature the ANE offers for iOS is Promoting In-App Purchases. Here’s some example code how to use the feature:
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_SUCCESS, setup_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_FAILURE, setup_failureHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASES_UPDATED, purchases_updatedHandler );
InAppBilling.service.addEventListener( PurchaseRequestEvent.SHOULD_ADD_PURCHASE, purchaseRequest_shouldAddPurchaseHandler );
InAppBilling.service.setup();
function purchaseRequest_shouldAddPurchaseHandler( event:PurchaseRequestEvent ):void
{
// Do any checks to see whether this should be added to the queue
var shouldAddPurchaseToQueue:Boolean = true;
InAppBilling.service.shouldAddPurchase( event.request, shouldAddPurchaseToQueue );
}
function purchases_updatedHandler( event:PurchaseEvent ):void
{
for each (var purchase:Purchase in event.data)
{
switch (purchase.transactionState)
{
case Purchase.STATE_PURCHASING:
case Purchase.STATE_DEFERRED:
case Purchase.STATE_PURCHASED:
case Purchase.STATE_FAILED:
case Purchase.STATE_REFUNDED:
case Purchase.STATE_RESTORED:
case Purchase.STATE_REMOVED:
case Purchase.STATE_CANCELLED:
case Purchase.STATE_NOTALLOWED:
InAppBilling.service.finishPurchase( purchase );
break;
}
}
}
From the wiki: „When a user doesn’t have your app installed but wants to buy a promoted in-app purchase, they'll receive a prompt to download the app first. Once the app is downloaded, the transaction will continue in the app.“
What I don’t understand is what happens inside the app, will the purchase flow start immediately on starting the app? What does the call InAppBilling.service.shouldAddPurchase()? Which purchase state will be dispatched in the purchases_updatedHandler?
Anybody using the Promoting In-App Purchases feature?