Integration
  • Overview
  • Getting Started
  • SDK Integration
    • Standard
    • Advanced
  • Game API
    • Overview
    • Games
    • Collections
    • Tokens
    • Marketplace
    • Transactions
    • Users
  • Misc
    • FAQ
    • Best Practices
    • Staging Environment
    • Account Management
    • Webhooks
    • IAP Setup
      • Android. How to create IAP Vessel Product
        • How to find Product ID
        • How to get Public Key
        • How to setup Google Service Account and get Credentials JSON File
      • iOS. How to create IAP Vessel Product
        • How to find Product ID
Powered by GitBook
On this page
  • Connect Wallet - Native
  • Load Balance Deeplink
  • Verify Wallet Address in Vessel Application
  • Disconnect a Wallet
  • Setup custom Load Balance logic
  • Set callback methods for handling IAP transactions

Was this helpful?

  1. SDK Integration

Advanced

Advanced features of our SDK:

Connect Wallet - Native

The code samples below trigger a wallet connection silently. No UI displays to the user. Your application is responsible for rendering the progress dialog, and for handling errors and allowing the user to cancel the app connect operation.

// Start connect flow
OVSdk.Sdk.AppConnectManager.ConnectWallet("in-game-user-id");

// Cancel currently active connect flow
OVSdk.Sdk.AppConnectManager.CancelConnect();
// Start connect flow
VesselSdk.getInstance( activity )
         .getAppConnectManager()
         .connectWallet("in-game-user-id");
         
// Cancel currently active connect flow
VesselSdk.getInstance( activity )
         .getAppConnectManager()
         .cancelConnect();Load Balance Deeplink
// Start connect flow
[[[OVLSdk sharedInstance] appConnectManager] 
    connectWalletWithUserId: @"in-game-user-id"];
         
// Cancel currently active connect flow
[[[OVLSdk sharedInstance] appConnectManager] cancelConnect];

Load Balance Deeplink

Load Balance allows Developer's to deeplink users directly into Vessel and prompt a coin purchase. Developers will use this feature under the circumstance they want a user to purchase an NFT but they do not have the sufficient amount of coins to do so:

// Deeplink to balance page
OVSdk.Sdk.WalletPresenter.LoadBalanceInWalletApplication(<wallet address>);

// Deeplink to balance page and prompt a specific purchase amount (i.e. - 70 coins)
OVSdk.Sdk.WalletPresenter.LoadBalanceInWalletApplication(<wallet address>, <coinamount>);
// Deeplink to balance page
VesselSdk.getInstance( this ).getWalletPresenter().loadBalanceInWalletApplication( <wallet address>, <activity>);

// Deeplink to balance page and prompt a specific purchase amount (i.e. - 70 coins)
VesselSdk.getInstance( this ).getWalletPresenter().loadBalanceInWalletApplication( <wallet address>, <coinamount>, <activity>);
// Deeplink to balance page
[OVLSdk.sharedInstance.presentationController loadBalanceInWalletApplication:<wallet address>];

// Deeplink to balance page and prompt a specific purchase amount (i.e. - 70 coins)
[OVLSdk.sharedInstance.presentationController loadBalanceInWalletApplication:<wallet address> byAmount:<coinamount>];

Verify Wallet Address in Vessel Application

Verify wallet address method lets you verify if the wallet address of the user is equal to the one, that he logged with, in the Vessel application. Note, that this method will redirect the user directly to the Vessel application after calling it, or advising him to install Vessel Wallet instead.

OVSdk.Sdk.WalletPresenter.VerifyWalletAddressInWalletApplication("wallet address");
final VesselSdk sdk = VesselSdk.getInstance(currentActivity);

sdk.getWalletPresenter().verifyWalletAddressInWalletApplication("wallet address", currentActivity);
[OVLSdk.sharedInstance.presentationController verifyWalletAddressInWalletApplication:@"wallet address"];

Disconnect a Wallet

Utilizing the following method disconnects a User's concurrently connected wallet and wipes the Vessel SDK state:

OVSdk.Sdk.AppConnectManager.DisconnectCurrentSession();
VesselSdk.getInstance( activity )
         .getAppConnectManager()
         .disconnectCurrentSession()
[[[OVLSdk sharedInstance] appConnectManager] 
  disconnectCurrentSessionWithResultHandler: ^{
    . . .
}];

Setup custom Load Balance logic

After pressing Load Balance button into your Profile page of your Vessel account in custom tab, Vessel SDK checks if custom presenter was used and overrided method could include your own screen to show available IAP products:

OVSdk.CustomPresenter.LoadBalancePresenter = ShowLoadBalance;

private void ShowLoadBalance()
{
    // ...
}
final VesselSdk sdk = VesselSdk.getInstance( currentActivity );
sdk.getWalletPresenter().setCustomPresenter( customPresenter );

// Custom Presenter definition
@Override
public boolean showLoadBalance()
{
    // ...
    return true;
}
OVLSdk.sharedInstance.presentationController.customPresenter = customPresenter;

// Custom Presenter definition
- (void)presentLoadBalance
{
    // ...
}

Set callback methods for handling IAP transactions

In order to follow the state of purchase, please use the next interface methods:

OVSdk.Sdk.IapManager.PurchaseProduct();

OVSdk.IapManagerCallbacks.OnPurchaseSuccess += PurchaseSuccess;
OVSdk.IapManagerCallbacks.OnPurchaseCancel += PurchaseCancelled; 
OVSdk.IapManagerCallbacks.OnPurchaseFailure += PurchaseFailed; 

public void PurchaseSuccess(OVSdk.SuccessfulPurchase successfulPurchase)
{
    // ...
}
public void PurchaseCancelled(OVSdk.CancelledPurchase cancelledPurchase)
{
    // ...
}
public void PurchaseFailed(OVSdk.FailedPurchase failedPurchase)
{
    // ...
}
final VesselSdk sdk = VesselSdk.getInstance(currentActivity);
sdk.getIapManager().purchaseProduct( productId, currentActivity ).whenComplete( (verificationObject, th) -> {
        if ( th != null )
        {
            final boolean isCancelled = Optional
                    .ofNullable( th.getCause() )
                    .filter( IapException.class::isInstance )
                    .map( IapException.class::cast )
                    .map( e -> e.isCanceled() )
                    .orElse( false );

        if ( isCancelled )
            {
            // handle cancel
            }
        else
            {
            // handle failure
            }
}
        else
            {
                // handle success
            }
        });
[OVLSdk.sharedInstance.iapManager setDelegate: self
                                    delegateQueue: dispatch_get_main_queue()];

[OVLSdk.sharedInstance.iapManager purchaseProductWithIdentifier:@"product id"];

// Delegate definition
- (void)iapManager:(OVIapManagerDelegateForwarder *)iapManager didCancelPurchaseWithProductIdentifier:(NSString *)productId 
{
    // ...
}

- (void)iapManager:(OVIapManagerDelegateForwarder *)iapManager didFailPurchaseWithProductIdentifier:(NSString *)productId error:(NSError *)error 
{
    // ...
}

- (void)iapManager:(OVIapManagerDelegateForwarder *)iapManager didCompletePurchaseWithProductIdentifier:(NSString *)productId receipt:(NSData *)receipt 
{
    // ...
}
PreviousStandardNextOverview

Last updated 2 years ago

Was this helpful?