store.canLoadProducts

Type Boolean
Revision Release 2024.3703
Keywords Apple, IAP, in-app purchases, canLoadProducts
See also store.loadProducts()
store.*

Overview

This property will be true if the store supports the loading of products. Following confirmation, the store.loadProducts() function can be used to retrieve information about items available for sale.

Syntax

store.canLoadProducts

Example

local store = require( "store" )

-- Transaction listener function
local function transactionListener( event )
    local transaction = event.transaction
end

-- Product listener function
local function productListener( event )
    print( "Valid products:", #event.products )
    print( "Invalid products:", #event.invalidProducts )
end

-- Initialize Apple IAP
store.init( transactionListener )

-- Sometime later, load products
if ( store.canLoadProducts ) then

    local productIdentifiers = {
        "com.coronalabs.ExampleInAppPurchase.Consumable",
        "com.coronalabs.ExampleInAppPurchase.NonConsumable"
    }
    store.loadProducts( productIdentifiers, productListener )
end