|
Project Information
|
PLEASE NOTE:This project has been discontinued and is not currently being supported due to changes in the terms of service in the iOS app store.
DownloadsScreenshot of the Offer Wall portion of the SDK Table Of Contents
Prerequisites:Before you can use the iOS SDK, please make sure the following tasks have been completed:
Unique App Identifier:The unique app identifier is an encrypted string that identifies your application. This identifier is created when you sign up for a SuperRewards Publisher account and create an app; if you have an app already, the unique app identifier has already been created for you. This app identifier is needed for the iOS SDK as it identifies the app that is making the request. To find your unique app identifier, you need to log in to your SuperRewards Publisher account and go to the "Apps" page. That page lists all the applications you've created and the associated "App Identifier" on the right side. Copy this value to use when implementing the SDK. iOS Setup - Full SDK:The full SDK includes the advertiser install tracker, the SuperRewards Offerwall and a user points lookup service, though you may chose to only implement the portions you need. If you only wish to purchase installs then it is recommended you install the lighter-weight install only SDK as described in the section below. There are some important items that are needed before you can set up your iOS application to track installs. These items and their specific instructions are outlined below. Unique App IdentifierIf you don't have your Unique App Identifier, please view the instructions above under 1. Prerequisites iOS SDK PackageThe Super Rewards iOS SDK consists of a library and resources that will be needed to display the offerwall within your game. Once the Super Rewards iOS SDK is located in the correct location, the classes can be imported and referenced when needed. SDK Location: http://code.google.com/p/superrewards-ios-sdk/downloads/list Note: You can also get the latest version of the SDK directly from the Subversion repository hosted on google code, but this is generally not recommended unless you are advised to do so by your account manager as it may contain untested coded that could introduce undesired effects within your application. Code SetupOnce you have downloaded the SDK the setup process is quite simple.
Open your project in Xcode. Control click on the top-level project item in the "Groups & Files" window and choose "Add -> Existing Files..." Navigate to where you have the SuperRewards SDK (the full version, not the install-only version) and select the "SDK" folder. You may optionally choose to copy the files into your project
#import "SuperRewards.h"
For this example, let's say you have a button set up that you'd like to make open the offerwall and the method wired up for that button looks like this -(IBAction) wallButtonHit {
// Your code here
}All you need to do is paste in code to create and open the offerwall, taking care to use your own app identifier. -(IBAction) wallButtonHit {
SuperRewards *sr = [[SuperRewards alloc] init];
[sr openWallWithApp:@"dvfyilhmp.881459721937" withUid:[[UIDevice currentDevice] uniqueIdentifier] withViewController:self];
}Note: We are using the device's unique identifier as the user ID in the above example. If you have another mechanism for identifying your users feel free to use that. iOS Setup - App Unlock Functionality:Description: The app unlock is a way for you to unlock some functionality in your application by having the user complete an offer. Example: You may have a game that offers 10 levels of play for free. The main menu could have a button linked to open the SuperRewards app unlock offer wall. To determine when the user has completed an offer, you call the SDK and it will make a request to the SuperRewards servers and return the lock status for that user. The result is also stored on the device so that future checks to determine a user's unlock status don't require a server-side check. When the user's unlock status is confirmed, you would then be able to make the appropriate changes in your program's logic to expose the new functionality. NOTE: Uou can NOT use both "earn" and "unlock" offer walls a single app Code SetupThe setup is very similar to the setup of the regular "earn" offer wall above. You will still need an application identifier (see 'Unique App Identifier' above).
Open your project in Xcode. Control click on the top-level project item in the "Groups & Files" window and choose "Add -> Existing Files..." Navigate to where you have the SuperRewards SDK (the full version, not the install-only version) and select the "SDK" folder. You may optionally choose to copy the files into your project
#import "SuperRewards.h"
For this example, let's say you have a button set up that you'd like to make open the offerwall and the method wired up for that button looks like this -(IBAction) unlockButtonHit {
// Your code here
}All you need to do is paste in code to create and open the offerwall, taking care to use your own app identifier. -(IBAction) unlockButtonHit {
if (!self.sr) {
self.sr = [[[SuperRewards alloc] initWithApplicationId:@"etksgxgonkp.882732194588" withUserId:[[UIDevice currentDevice] uniqueIdentifier] withViewController:self] autorelease];
}
[sr openUnlockWall];
}Note: We are using the device's unique identifier as the user ID in the above example. If you have another mechanism for identifying your users feel free to use that. Determining a user's unlock statusThe mechanism to check the lock status uses the delegate pattern. You make a call to check the status with appGateCheckUnlock: and provide a delegate object that will implement the callback selector of didFinishAppGateCheck.
// this is wired to a button just for example
- (IBAction) unlockButtonHit {
if (!self.sr) {
self.sr = [[[SuperRewards alloc] initWithApplicationId:@"etksgxgonkp.882732194588" withUserId:[[UIDevice currentDevice] uniqueIdentifier] withViewController:self] autorelease];
}
// we fire an appGateCheck with self as a delegate to receive the didFinishAppGateCheck: message
BOOL isUnlocked;
isUnlocked = [sr appGateCheckUnlock:self];
// while you could check isUnlocked now, it will only be YES if it had already been unLocked
// otherwise, it has filed an asynchronous requests and you should implement the callback by
// implementing the didFinishAppGateCheck: method of some SRAppGateDelegate which you would
// have been passed in above to appGateCheckUnlock:
}
- (void)didFinishAppGateCheck:(BOOL)success {
if (success) {
// this is where you'd implement your unlock code
lockStatusField.text = @"UNLOCKED";
} else {
lockStatusField.text = @"APP IS LOCKED";
}
}Testing the App Unlock featurePicking User IDs to testDuring your development process you'll clearly want to test the app unlock feature. Right now there is not any way to revert a user's unlock status on our servers so when you are testing, you will want to use user ID's that won't match any potential user IDs after launch. Example: most developers will simply use the device UDID as a user ID so just use something that doesn't look like a device UDID, such as "1000". Then when you unlock that user and need to test again use "1001". Testing the Unlock processTo test that a user completed an offer, you can set up a test offer that is only visible to you. By logging on to the srpoints.com website and editing your app, you can add test user IDs in the "Admin User IDs" section. Once you have saved this setting (changes may take a few minutes to propogate), you should see a "test postback" offer in your offer list when you open the unlock wall using one of the admin user IDs. Click that offer and click the "complete offer" button. You should see a landing page that has a message saying your points will be awarded. The next time you check that user's unlock status you should get a successful response. Unfortunately you cannot "revert" that user to a locked status so you will need to change the testing user ID each time you will test the unlock functionality. You can help yourself out here by adding a few user IDs to the Admin User IDs ahead of time like "1000,1001,1002,1003,1004,1005". Then just change it in your app when you need to retest. IMPORTANT NOTE ABOUT CACHING: When the app gate gets a successful unlock response from our servers, it stores it on the device (for that app) so that it remains unlocked even if the user goes offline. We also do this because it is faster to keep it cached for subsequent unlock checks instead of waiting for a server response when we know the user has previously unlocked this app. This means that when you change your test user, you will need to wipe this key as well. You should not need to do this in the release version of your app. You can clear the cached value from system defaults using the following code, where kSRAppGateUnlockedKey is a NSString from the SRGlobalParams.h file, @"SRAppGateUnlocked". NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
if (standardUserDefaults) {
[standardUserDefaults removeObjectForKey:kSRAppGateUnlockedKey];
}See the SDKDemo project for a working example. iOS Setup - Only Install Tracking SDK:IMPORTANT NOTE : This doc only covers using the install tracking SDK required for purchasing and tracking app installs. The full SDK which supports app monetization features is described above. There are some important items that are needed before you can set up your iOS application to track installs. These items and their specific instructions are outlined below.
SDK Location: http://code.google.com/p/superrewards-ios-sdk/downloads/list
The SRInstallTracker.h and SRInstallTracker.m files will need to be added to your project.
#import "MyAppDelegate.h";
#import "SRInstallTracker.h";
@implementation MyAppDelegate
@synthesize window;
@synthesize viewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
BOOL success = [SRInstallTracker trackApp:@"xxxxx.xxxxxxxxxx"];
}User Points SDK:
Normally, an application will set up a postback URL to receive a notification but if a developer doesn't have their own server to receive postbacks then they can chose to use our points service. With this, they can call our servers any time they want to check a user's point balance and it will respond with the total awarded points and the newly awarded points (since the last time points were requested.) Retrieving User Points To retrieve a user's points, you send getUserPoints:withUserId: message to a SRUserPoints object. The SRUserPoints object should have been init'ed with a delegate that implements the SRUserPointsDelegate protocol. This delegate will receive a callback message of userPointsLoaded: when the points are loaded. It is recommended you look at the latest SDK Demo Application on the Downloads page to see how this is implemented. EXAMPLECompleting a user points request from within some view controller. In this example, we will just use our view controller as our delegate to receive the points callback though you could make this part of some other class that controls your game logic, store, etc. Import the header in your .h file: #import "SRUserPoints.h" We're going to implement the SRUserPointsDelegate protocol in our view controller by adding it to the interface definition like this: @interface SDKDemoViewController : UIViewController <SRUserPointsDelegate> {Now we have create some method in our view controller to fire the points request, notice that we are setting ourself as the delegate using initWithDelegate: -(IBAction) pointsButtonHit {
// The delegate you assign should support implement the SRUserPointsDelegate protocol,
// specifically the userPointsLoaded: method, to receive the updated SRUserPoints values
// via this callback. Otherwise, nothing will happen.
SRUserPoints *points = [[[SRUserPoints alloc] initWithDelegate:self] autorelease];
[points getUserPoints:@"dvfyilhmp.881459721937" withUserId:[[UIDevice currentDevice] uniqueIdentifier]];
}Finally, since we are the delegate, we need to implement the method to handle the points callback: -(void) userPointsLoaded:(SRUserPoints *)userPoints {
// You should check the success bool to see if the request worked.
// Here, we are just setting a label for example.
if (userPoints.success == YES) {
// We just log for this example
NSLog(@"%@ newPoints", userPoints.newPoints);
NSLog(@"%@ totalPoints", userPoints.totalPoints);
} else {
// Your application should have logic to handle being offline
NSLog(@"Request failed. Probably no network.");
}
}Additional Help:API ReferenceFor additional information on the specific classes, please refer to the API Reference ContactFor more help regarding the setup of the iOS SDK, please contact your Account Manager. |