Inherits from NSObject
Conforms to NSURLConnectionDataDelegate
NSURLConnectionDelegate
Declared in SPVirtualCurrencyServerConnector.h
SPVirtualCurrencyServerConnector.m

Overview

The SPVirtualCurrencyServerConnector class provides functionality to query SponsorPay’s Virtual Currency Servers to obtain the number of virtual coins the user has earned.

It keeps track of the last time the amount of earned coins was requested for a given user, reporting newly earned amounts between successive requests, even across application sessions.

The client is authenticated to the virtual currency server by signing URL requests with the secret token or key that SponsorPay has assigned to your publisher account, and that you must provide when initializing the SDK (@see SponsorPaySDK).

Answers to the requests are asynchronously reported to your registered delegate through the selectors defined in the SPVirtualCurrencyConnectionDelegate protocol.

Tasks

Authenticating the request and the signature

  •   secretToken

    The token to access your account on SponsorPay’s virtual currency server.
    This token is used to sign requests to and verify responses from the SponsorPay currency server.

    property
  •   responseSignature

    Signature of the last response received from the server
    This is used in combination with secretToken to validate the authenticity of the response.

    property

Obtaining the last transaction ID

Being notified asyncronously of server responses and errors

Properties

delegate

Delegate to be notified of answers to requests and error conditions.
Answers to the requests are asynchronously reported to your registered delegate through the selectors defined in the SPVirtualCurrencyConnectionDelegate protocol.

@property (unsafe_unretained) id<SPVirtualCurrencyConnectionDelegate> delegate

Declared In

SPVirtualCurrencyServerConnector.h

latestTransactionId

Latest transaction ID for your user and app IDs, as reported by the server.
This is used to keep track of new transactions between invocations to fetchDeltaOfCoins.

@property (retain, nonatomic) NSString *latestTransactionId

Declared In

SPVirtualCurrencyServerConnector.h

responseSignature

Signature of the last response received from the server
This is used in combination with secretToken to validate the authenticity of the response.

@property (retain) NSString *responseSignature

Declared In

SPVirtualCurrencyServerConnector.h

secretToken

The token to access your account on SponsorPay’s virtual currency server.
This token is used to sign requests to and verify responses from the SponsorPay currency server.

@property (retain) NSString *secretToken

Declared In

SPVirtualCurrencyServerConnector.h

Instance Methods

addFetchDeltaOfCoinsCompletionBlock:

Adds a completion handler that will be run when a successful answer to fetchDeltaOfCoins is received.

Though you could use this method to obtain the same functionality that registering a SPVirtualCurrencyConnectionDelegate offers for being notified of the amount of coins earned by the user, relying on the delegate is the recommended way of being notified of the results of the request, as it can handle error conditions.

- (void)addFetchDeltaOfCoinsCompletionBlock:(SPVCSDeltaOfCoinsRequestCompletionBlock)completionBlock

Parameters

completionBlock

Block to be run when a successful answer to the delta of coins request is received.

Discussion

The supplied handler will be run in the main thread. Multiple completion handlers can be specified in successive calls and they will run in the order in which they were added.

Declared In

SPVirtualCurrencyServerConnector.h

fetchDeltaOfCoins

Fetches the amount of coins earned since the last time this method was invoked for the current user ID / app ID combination.

- (void)fetchDeltaOfCoins

Discussion

This involves a network call which will be performed in the background. When the answer from the server is received, your registered delegate will be notified.

Declared In

SPVirtualCurrencyServerConnector.h

initWithUserId:appId:secretToken:

This initializer has been deprecated and will be removed from a future SDK release. Please don’t initialize this class directly, rather access it through [SponsorPaySDK VCSConnector] or [SponsorPaySDK VCSConnectorForCredentials:].

- (id)initWithUserId:(NSString *)userId appId:(NSString *)appId secretToken:(NSString *)secretToken

Declared In

SPVirtualCurrencyServerConnector.h