Objective-C Client Reference
Class PIOPayVault
Language: Objective-C
The Player.IO PayVault.
Instances of this class represent a specific user's Vault, and contains methods and properties both for inspecting and manipulating the contents.
All properties and methods that inspect the Vault requires that it is up-to-date first. This can be achieved explicitly by calling the -refresh: method or implicitly by calling any method which modifies the Vault.
Here is how to read the Coins balance:
This is how you check if an item exists:
Credit and Debit can be used like this:
Buying items with Coins is really easy. This example requires that you have created an item in the PayVaultItems table in BigDB with the key "speedboost", and a property "PriceCoins" containing the price.
And here's how to consume an item:
When it's time for a user to add more Coins, you can do it like this:
And this is how to let the user buy an item directly. This requires that you have created an item in the PayVaultItems table in BigDB with the key "supercar", and a property "PriceUSD" containing the price.
Finally, there are methods for retrieving the payment history of a user:
Methods | |||
---|---|---|---|
- (void) |
|
||
- (void) |
|
||
- (long) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (NSUInteger) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (PIOVaultItem*) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (BOOL) |
|
||
- (NSArray*) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
||
- (void) |
|
buyItems:storeItems:successBlock:
Buy items with Coins.
Arguments
NSArray* | items |
BOOL | storeItems |
void(^)(void) | successBlock |
Throws
PlayerIOError |
buyItems:storeItems:successBlock:errorBlock:
Buy items with Coins.
Arguments
NSArray* | items |
BOOL | storeItems |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
coins
Get the current coin balance in this Vault. This method can only be called on an up-to-date vault.
Return Value
long | |
consumeItem:successBlock:
Consume an item in the Vault. This will cause the item to be removed. The action will not show up in the vault history.
Arguments
PIOVaultItem* | item |
void(^)(void) | successBlock |
Throws
PlayerIOError |
consumeItem:successBlock:errorBlock:
Consume an item in the Vault. This will cause the item to be removed. The action will not show up in the vault history.
Arguments
PIOVaultItem* | item |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
consumeItems:successBlock:
Consume items in this Vault. This will cause them to be removed. The action will not show up in the vault history.
Arguments
NSArray* | items |
void(^)(void) | successBlock |
Throws
PlayerIOError |
consumeItems:successBlock:errorBlock:
Consume items in this Vault. This will cause them to be removed. The action will not show up in the vault history.
Arguments
NSArray* | items |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
countOfItem:
Returns the number of items of a given itemKey is in this Vault. This method can only be called on an up-to-date vault.
Arguments
NSString* | itemKey |
Return Value
NSUInteger | The number of items of the given type that the user has in the vault. |
Throws
PlayerIOError |
creditCoins:reason:successBlock:
Give coins to this Vault
Arguments
NSUInteger | coinAmount |
NSString* | reason |
void(^)(void) | successBlock |
Throws
PlayerIOError |
creditCoins:reason:successBlock:errorBlock:
Give coins to this Vault
Arguments
NSUInteger | coinAmount |
NSString* | reason |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
debitCoins:reason:successBlock:
Take coins from this Vault
Arguments
NSUInteger | coinAmount |
NSString* | reason |
void(^)(void) | successBlock |
debitCoins:reason:successBlock:errorBlock:
Take coins from this Vault
Arguments
NSUInteger | coinAmount |
NSString* | reason |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
firstItem:
Returns the first item of the given itemKey from this Vault. This method can only be called on an up-to-date vault.
Arguments
NSString* | itemKey |
Return Value
PIOVaultItem* | A VaultItem if one was found, or null if not. |
Throws
PlayerIOError |
getBuyCoinsInfoWithProvider:purchaseArguments:successBlock:
Gets information about how to make a coin purchase with the specified PayVault provider.
Arguments
NSString* | provider |
NSDictionary* | purchaseArguments |
void(^)(NSDictionary*) | successBlock |
Throws
PlayerIOError |
getBuyCoinsInfoWithProvider:purchaseArguments:successBlock:errorBlock:
Gets information about how to make a coin purchase with the specified PayVault provider.
Arguments
NSString* | provider |
NSDictionary* | purchaseArguments |
void(^)(NSDictionary*) | successBlock |
void(^)(PIOError*error) | errorBlock |
getBuyDirectInfoWithProvider:purchaseArguments:items:successBlock:
Gets information about how to make a direct item purchase with the specified PayVault provider.
Arguments
NSString* | provider |
NSDictionary* | purchaseArguments |
NSArray* | items |
void(^)(NSDictionary*) | successBlock |
Throws
PlayerIOError |
getBuyDirectInfoWithProvider:purchaseArguments:items:successBlock:errorBlock:
Gets information about how to make a direct item purchase with the specified PayVault provider.
Arguments
NSString* | provider |
NSDictionary* | purchaseArguments |
NSArray* | items |
void(^)(NSDictionary*) | successBlock |
void(^)(PIOError*error) | errorBlock |
giveItems:successBlock:
Give the user items without taking any of his coins from the vault.
Arguments
NSArray* | items |
void(^)(void) | successBlock |
Throws
PlayerIOError |
giveItems:successBlock:errorBlock:
Give the user items without taking any of his coins from the vault.
Arguments
NSArray* | items |
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
hasItem:
This method checks if the Vault contains at least one item of the given itemKey. This method can only be called on an up-to-date vault.
Arguments
NSString* | itemKey |
Return Value
BOOL | True if the user has at least one item of the given type (itemKey). |
Throws
PlayerIOError |
items
Get the list of items in this Vault. This method can only be called on an up-to-date vault.
Return Value
NSArray* | |
readHistoryWithPage:pageSize:successBlock:
Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.
Arguments
NSUInteger | page |
NSUInteger | pageSize |
void(^)(NSArray*historyEntries) | successBlock |
Throws
PlayerIOError |
readHistoryWithPage:pageSize:successBlock:errorBlock:
Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first.
Arguments
NSUInteger | page |
NSUInteger | pageSize |
void(^)(NSArray*historyEntries) | successBlock |
void(^)(PIOError*error) | errorBlock |
refreshWithSuccessBlock:
Refreshes this Vault, making sure the Items and Coins are up-to-date.
Arguments
void(^)(void) | successBlock |
Throws
PlayerIOError |
refreshWithSuccessBlock:errorBlock:
Refreshes this Vault, making sure the Items and Coins are up-to-date.
Arguments
void(^)(void) | successBlock |
void(^)(PIOError*error) | errorBlock |
useBuyInfoWithProvider:providerArguments:successBlock:
Use information from a provider to finalize a purchase with the specified PayVault provider.
Arguments
NSString* | provider |
NSDictionary* | providerArguments |
void(^)(NSDictionary*) | successBlock |
useBuyInfoWithProvider:providerArguments:successBlock:errorBlock:
Use information from a provider to finalize a purchase with the specified PayVault provider.
Arguments
NSString* | provider |
NSDictionary* | providerArguments |
void(^)(NSDictionary*) | successBlock |
void(^)(PIOError*error) | errorBlock |