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
-
secretTokenThe token to access your account on SponsorPay’s virtual currency server.
property -
responseSignatureSignature of the last response received from the server
property
Obtaining the last transaction ID
-
latestTransactionIdLatest transaction ID for your user and app IDs, as reported by the server.
property
Being notified asyncronously of server responses and errors
-
delegateDelegate to be notified of answers to requests and error conditions.
property -
– addFetchDeltaOfCoinsCompletionBlock:Adds a completion handler that will be run when a successful answer to fetchDeltaOfCoins is received.
-
– 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:].
-
– fetchDeltaOfCoinsFetches 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.
@property (unsafe_unretained) id<SPVirtualCurrencyConnectionDelegate> delegateDiscussion
Answers to the requests are asynchronously reported to your registered delegate through the selectors defined in the SPVirtualCurrencyConnectionDelegate protocol.
Declared In
SPVirtualCurrencyServerConnector.hlatestTransactionId
Latest transaction ID for your user and app IDs, as reported by the server.
@property (retain, nonatomic) NSString *latestTransactionIdDiscussion
This is used to keep track of new transactions between invocations to fetchDeltaOfCoins.
Declared In
SPVirtualCurrencyServerConnector.hresponseSignature
Signature of the last response received from the server
@property (retain) NSString *responseSignatureDiscussion
This is used in combination with secretToken to validate the authenticity of the response.
Declared In
SPVirtualCurrencyServerConnector.hInstance Methods
addFetchDeltaOfCoinsCompletionBlock:
Adds a completion handler that will be run when a successful answer to fetchDeltaOfCoins is received.
- (void)addFetchDeltaOfCoinsCompletionBlock:(SPVCSDeltaOfCoinsRequestCompletionBlock)completionBlockParameters
- completionBlock
Block to be run when a successful answer to the delta of coins request is received.
Discussion
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.hfetchDeltaOfCoins
Fetches the amount of coins earned since the last time this method was invoked for the current user ID / app ID combination.
- (void)fetchDeltaOfCoinsDiscussion
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.hinitWithUserId: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 *)secretTokenDeclared In
SPVirtualCurrencyServerConnector.h