SPVirtualCurrencyServerConnector Class Reference
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.
property
This token is used to sign requests to and verify responses from the SponsorPay currency server. -
responseSignature
Signature of the last response received from the server
property
This is used in combination with secretToken to validate the authenticity of the response.
Obtaining the last transaction ID
-
latestTransactionId
Latest transaction ID for your user and app IDs, as reported by the server.
property
This is used to keep track of new transactions between invocations to fetchDeltaOfCoins.
Being notified asyncronously of server responses and errors
-
delegate
Delegate to be notified of answers to requests and error conditions.
property
Answers to the requests are asynchronously reported to your registered delegate through the selectors defined in the SPVirtualCurrencyConnectionDelegate protocol. -
– 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.
-
– fetchDeltaOfCoins
Fetches the amount of coins earned since the last time this method was invoked for the current user ID / app ID combination.
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
Discussion
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.
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
Discussion
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.
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
Discussion
Signature of the last response received from the server
This is used in combination with secretToken to validate the authenticity of the response.
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
Discussion
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.
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
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.
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
Fetches the amount of coins earned since the last time this method was invoked for the current user ID / app ID combination.
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