{"__v":45,"_id":"542ab90154d88d140075fbd4","category":{"__v":22,"_id":"542998547a6b690800768072","pages":["542a3de5e677b0080050898f","544e8298de6bac1000236fe9","542998547a6b690800768074","542ab90154d88d140075fbd4","5433300867f20a080097a04b","5433302067f20a080097a04d","544e7ae6de6bac1000236fb5","54330b4990d63b1c0030c129","543da24b31ca981a00a6ffe7","54333238a807e208003e72d2","544e8305bd51b9080037f9cb","54332b234aeeef0800410a73","5433306067f20a080097a051","543db19f31ca981a00a70053","543d31d6a10ab32000b3aa70","54a1f0af50465f1f00bfa3e8","54cfc5925ff7e617002bbda5","54f4f09158e9df0d00917b3e"],"project":"542998547a6b69080076806e","version":"542998547a6b690800768071","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-09-29T17:35:16.267Z","from_sync":false,"order":0,"slug":"getting-started","title":"Getting Started"},"is_link":false,"parentDoc":null,"project":"542998547a6b69080076806e","user":"542998207a6b690800768069","version":{"__v":9,"_id":"542998547a6b690800768071","project":"542998547a6b69080076806e","createdAt":"2014-09-29T17:35:16.249Z","releaseDate":"2014-09-29T17:35:16.249Z","categories":["542998547a6b690800768072","5433027990d63b1c0030c0f1","5433028190d63b1c0030c0f2","5433028d9a2b451a00ad4508","5433055790d63b1c0030c10a","5461417d37e5bc200049e1e4","54624066ddd31b0800a58db4","54625de66d1f1010002f3901","54d309955616470d0013cc55"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["5449ec2d778b3e08002b224f","5449ed4a27b7fc140078da31","5449ee3327b7fc140078da33","5449f06827b7fc140078da35","5449f32327b7fc140078da37","5449f433778b3e08002b2264","56be28a80d53850d00cb3942"],"next":{"pages":[],"description":""},"createdAt":"2014-09-30T14:06:57.996Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":3,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Create a Publisher Account\"\n}\n[/block]\nA Publisher Account is required to use your application, website or game with SuperRewards.\n\nIf you have not already done so, register for a Publisher Account at [pub.superrewards.com](https://pub.superrewards.com/signup).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Our iOS SDK\"\n}\n[/block]\nOur iOS SDK allows you to present an offer wall whenever it's appropriate in your native app, receive notifications of user transactions, and more. Using the offer wall in your app involves three steps:\n\n1. [Install our SDK](#header-install)\n2. [Display the offer wall to a user](#header-display)\n3. [Get notified of new points available](#header-notification)\n\nThere are also notes below about how to:\n* [Test it out](#header-test)\n* [Get paid](#header-paid)\n[block:html]\n{\n  \"html\": \"<a name='header-install'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Install our SDK\"\n}\n[/block]\n* Download the [zip file of our iOS SDK](http://files.superrewards.com/SDKs/ios/SuperRewards.framework-3.1b.zip)\n* Drag the `SuperRewards.framework` folder into your project's `Frameworks` binder.\n* Select the \"Build Phases\" tab from your project settings and make sure Foundation.framework is included in the \"Link Binary With Libraries\" section.\n* Keep your hash string (App ID) handy for when you want to show the offer wall. You can find it in your [Dashboard](https://pub.superrewards.com). For more info see [Foundation: Hashes and Keys](doc:foundation-app-hashes-keys-and-signing).\n[block:html]\n{\n  \"html\": \"To get your app hash and try it out, <a class=\\\"btn btn-primary\\\" role=\\\"button\\\" href='https://pub.superrewards.com/signup'>Sign up</a> or <a href='https://pub.superrewards.com/login'>Log in</a>.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Header Files\",\n  \"body\": \"We provide a single header file that will import other necessary headers. To make it even easier, you may want to include it in your project's `.pch` file:\\n```Objective-C\\n#import <SuperRewards/SuperRewards.h>\\n```\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<a name='header-display'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Display the Offer Wall to a user\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <SuperRewards/SuperRewards.h>\\n\\nSuperRewards *sr = [[SR sharedManager] \\n                    initWithAppId::::at:::\\\"<YOUR APP ID>\\\" \\n                    withUserId:@\\\"<YOUR USER'S ID>\\\"\\n                    withViewController:self];\\n\\n[sr openWall];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nThe `withUserId` field should be a unique ID for the user, either numeric or text. Check out our [Notes on UIDs](doc:notes-on-uids). \n[block:html]\n{\n  \"html\": \"<a name='header-notification'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Get notified of transactions\"\n}\n[/block]\nWhenever your app wants to check for new completed transactions, it should call `getUserPoints`.  This API call is asynchronous, and when it completes it will trigger a callback function in your class or post a NSNotification.\n\nWith version 3.1b of the iOS SDK, automated points polling is started automatically for you when you first instantiate the Super Rewards object. The default behaviour when the update is successful is to use NSNotificationCenter to post a SRUserPoints object with the name 'SR_EVENT_USER_POINTS'.\n\nIf you prefer to use a delegate method, simply request a points update including your delegate class to the Super Rewards object described below. The SuperRewards SDK will then change its behaviour of using NSNotificationCenter to using your points delegate class.\n\n### Using a Delegate Method\n\nFor any class you would like to use to receive Super Rewards points updates using a delegate, add the delegate `SRUserPointsDelegate`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <SuperRewards/SuperRewards.h>\\n\\n@interface ViewController : UIViewController <SRUserPointsDelegate>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nThen call the `getUserPoints` with the SuperRewards class and your delegate:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"SuperRewards *sr = [[SR sharedManager] getUserPoints:self];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n* NOTE: ensure that you have initialized the SuperRewards object first as described above\n\nThis will then call the function you see below, \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-(void)userPointsLoaded:(SRUserPoints*)userPoints\\n{\\n  // assuming you have totalPoints, freshPoints and pendingPoints already\\n    [totalPoints setText:[NSString stringWithFormat:@\\\"%d points\\\", userPoints.pointsTotal]];\\n    [freshPoints setText:[NSString stringWithFormat:@\\\"%d points\\\", userPoints.pointsNew]];\\n    [pendingPoints setText:[NSString stringWithFormat:@\\\"%d points\\\", userPoints.pointsPending]];\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n* `freshPoints` is the \"newly earned\" points since the last time you checked\n* `totalPoints` is the running total of all points earned by the user\n* `pendingPoints` are points from offers that are waiting to be confirmed as completed\n[block:html]\n{\n  \"html\": \"<a name='header-test'></a>\"\n}\n[/block]\n### Using NSNotification\n\nIf you prefer to use iOS' NSNotificationCenter, create an NSNotification observer in the class that will handle the points notification:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \".\\n.\\n\\t[[NSNotificationCenter defaultCenter] addObserver:self\\n   \\tselector:@selector(userPointsHandler)\\n \\t\\tname:@\\\"SR_EVENT_USER_POINTS\\\"\\n \\t\\tobject:nil];\\n.\\n.\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\nAnd and example of the method that would handle the NSNotification:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"-(void)userPointsLoaded:(NSNotification*)notification\\n{\\n    if ([notification.object isKindOfClass:[SRUserPoints class]]) {\\n        SRUserPoints *userPoints = notification.object;\\n        [totalPoints setText:[NSString stringWithFormat:@\\\"%f points\\\", userPoints.pointsTotal]];\\n        [freshPoints setText:[NSString stringWithFormat:@\\\"%f points\\\", userPoints.pointsNew]];\\n        [pendingPoints setText:[NSString stringWithFormat:@\\\"%f points\\\", userPoints.pointsPending]];\\n    } else {\\n        NSLog(@\\\"Error, object not recognised.\\\");\\n    }\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. Test it out\"\n}\n[/block]\nComing soon: we will make it possible to fire notifications to your app, to test the full process.\n[block:html]\n{\n  \"html\": \"<a name='header-paid'></a>\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"5. Get Paid\"\n}\n[/block]\nCheck your earnings in real-time in your [Dashboard](https://pub.superrewards.com).  We do payouts every two weeks, and our fees are the best around, check out the details in [Basics: Getting Paid](doc:basics-getting-paid).\n[block:html]\n{\n  \"html\": \"Enter your banking information in your <a href='https://pub.superrewards.com/account'>Dashboard</a>, or  <a class=\\\"btn btn-primary\\\" role=\\\"button\\\" href='https://pub.superrewards.com/signup'>Sign up</a>.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"6. Updates And Changes\"\n}\n[/block]\n22Apr2015 - 3.1b\n* SDK now does automatic polling for user points\n* Updated sample app, [available here](http://files.superrewards.com/SDKs/ios/iOSDemo-1.3b.zip)\n\n23Mar2015 - 3.0b \n* updated to take advantage of the new Super Rewards offer wall\n* better filtering of offers based on device capabilities\n* viewing offer detail then moving to completing an offer takes the user out to Safari or other external web browser. Note: please ensure your app is set up to handle exiting to an external app to provide the best user experience.\n* [Click here to download the Super Rewards iOS SDK version 3.0b](http://files.superrewards.com/SDKs/ios/SuperRewards.framework-3.0b.zip)","excerpt":"Offer walls on iOS","slug":"getting-started-ios","type":"basic","title":"Getting Started - iOS"}

Getting Started - iOS

Offer walls on iOS

[block:api-header] { "type": "basic", "title": "Create a Publisher Account" } [/block] A Publisher Account is required to use your application, website or game with SuperRewards. If you have not already done so, register for a Publisher Account at [pub.superrewards.com](https://pub.superrewards.com/signup). [block:api-header] { "type": "basic", "title": "Our iOS SDK" } [/block] Our iOS SDK allows you to present an offer wall whenever it's appropriate in your native app, receive notifications of user transactions, and more. Using the offer wall in your app involves three steps: 1. [Install our SDK](#header-install) 2. [Display the offer wall to a user](#header-display) 3. [Get notified of new points available](#header-notification) There are also notes below about how to: * [Test it out](#header-test) * [Get paid](#header-paid) [block:html] { "html": "<a name='header-install'></a>" } [/block] [block:api-header] { "type": "basic", "title": "1. Install our SDK" } [/block] * Download the [zip file of our iOS SDK](http://files.superrewards.com/SDKs/ios/SuperRewards.framework-3.1b.zip) * Drag the `SuperRewards.framework` folder into your project's `Frameworks` binder. * Select the "Build Phases" tab from your project settings and make sure Foundation.framework is included in the "Link Binary With Libraries" section. * Keep your hash string (App ID) handy for when you want to show the offer wall. You can find it in your [Dashboard](https://pub.superrewards.com). For more info see [Foundation: Hashes and Keys](doc:foundation-app-hashes-keys-and-signing). [block:html] { "html": "To get your app hash and try it out, <a class=\"btn btn-primary\" role=\"button\" href='https://pub.superrewards.com/signup'>Sign up</a> or <a href='https://pub.superrewards.com/login'>Log in</a>." } [/block] [block:callout] { "type": "info", "title": "Header Files", "body": "We provide a single header file that will import other necessary headers. To make it even easier, you may want to include it in your project's `.pch` file:\n```Objective-C\n#import <SuperRewards/SuperRewards.h>\n```" } [/block] [block:html] { "html": "<a name='header-display'></a>" } [/block] [block:api-header] { "type": "basic", "title": "2. Display the Offer Wall to a user" } [/block] [block:code] { "codes": [ { "code": "#import <SuperRewards/SuperRewards.h>\n\nSuperRewards *sr = [[SR sharedManager] \n initWithAppId:@\"<YOUR APP ID>\" \n withUserId:@\"<YOUR USER'S ID>\"\n withViewController:self];\n\n[sr openWall];", "language": "objectivec" } ] } [/block] The `withUserId` field should be a unique ID for the user, either numeric or text. Check out our [Notes on UIDs](doc:notes-on-uids). [block:html] { "html": "<a name='header-notification'></a>" } [/block] [block:api-header] { "type": "basic", "title": "3. Get notified of transactions" } [/block] Whenever your app wants to check for new completed transactions, it should call `getUserPoints`. This API call is asynchronous, and when it completes it will trigger a callback function in your class or post a NSNotification. With version 3.1b of the iOS SDK, automated points polling is started automatically for you when you first instantiate the Super Rewards object. The default behaviour when the update is successful is to use NSNotificationCenter to post a SRUserPoints object with the name 'SR_EVENT_USER_POINTS'. If you prefer to use a delegate method, simply request a points update including your delegate class to the Super Rewards object described below. The SuperRewards SDK will then change its behaviour of using NSNotificationCenter to using your points delegate class. ### Using a Delegate Method For any class you would like to use to receive Super Rewards points updates using a delegate, add the delegate `SRUserPointsDelegate`: [block:code] { "codes": [ { "code": "#import <SuperRewards/SuperRewards.h>\n\n@interface ViewController : UIViewController <SRUserPointsDelegate>", "language": "objectivec" } ] } [/block] Then call the `getUserPoints` with the SuperRewards class and your delegate: [block:code] { "codes": [ { "code": "SuperRewards *sr = [[SR sharedManager] getUserPoints:self];", "language": "objectivec" } ] } [/block] * NOTE: ensure that you have initialized the SuperRewards object first as described above This will then call the function you see below, [block:code] { "codes": [ { "code": "-(void)userPointsLoaded:(SRUserPoints*)userPoints\n{\n // assuming you have totalPoints, freshPoints and pendingPoints already\n [totalPoints setText:[NSString stringWithFormat:@\"%d points\", userPoints.pointsTotal]];\n [freshPoints setText:[NSString stringWithFormat:@\"%d points\", userPoints.pointsNew]];\n [pendingPoints setText:[NSString stringWithFormat:@\"%d points\", userPoints.pointsPending]];\n}", "language": "objectivec" } ] } [/block] * `freshPoints` is the "newly earned" points since the last time you checked * `totalPoints` is the running total of all points earned by the user * `pendingPoints` are points from offers that are waiting to be confirmed as completed [block:html] { "html": "<a name='header-test'></a>" } [/block] ### Using NSNotification If you prefer to use iOS' NSNotificationCenter, create an NSNotification observer in the class that will handle the points notification: [block:code] { "codes": [ { "code": ".\n.\n\t[[NSNotificationCenter defaultCenter] addObserver:self\n \tselector:@selector(userPointsHandler)\n \t\tname:@\"SR_EVENT_USER_POINTS\"\n \t\tobject:nil];\n.\n.\n", "language": "objectivec" } ] } [/block] And and example of the method that would handle the NSNotification: [block:code] { "codes": [ { "code": "-(void)userPointsLoaded:(NSNotification*)notification\n{\n if ([notification.object isKindOfClass:[SRUserPoints class]]) {\n SRUserPoints *userPoints = notification.object;\n [totalPoints setText:[NSString stringWithFormat:@\"%f points\", userPoints.pointsTotal]];\n [freshPoints setText:[NSString stringWithFormat:@\"%f points\", userPoints.pointsNew]];\n [pendingPoints setText:[NSString stringWithFormat:@\"%f points\", userPoints.pointsPending]];\n } else {\n NSLog(@\"Error, object not recognised.\");\n }\n}", "language": "objectivec" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. Test it out" } [/block] Coming soon: we will make it possible to fire notifications to your app, to test the full process. [block:html] { "html": "<a name='header-paid'></a>" } [/block] [block:api-header] { "type": "basic", "title": "5. Get Paid" } [/block] Check your earnings in real-time in your [Dashboard](https://pub.superrewards.com). We do payouts every two weeks, and our fees are the best around, check out the details in [Basics: Getting Paid](doc:basics-getting-paid). [block:html] { "html": "Enter your banking information in your <a href='https://pub.superrewards.com/account'>Dashboard</a>, or <a class=\"btn btn-primary\" role=\"button\" href='https://pub.superrewards.com/signup'>Sign up</a>." } [/block] [block:api-header] { "type": "basic", "title": "6. Updates And Changes" } [/block] 22Apr2015 - 3.1b * SDK now does automatic polling for user points * Updated sample app, [available here](http://files.superrewards.com/SDKs/ios/iOSDemo-1.3b.zip) 23Mar2015 - 3.0b * updated to take advantage of the new Super Rewards offer wall * better filtering of offers based on device capabilities * viewing offer detail then moving to completing an offer takes the user out to Safari or other external web browser. Note: please ensure your app is set up to handle exiting to an external app to provide the best user experience. * [Click here to download the Super Rewards iOS SDK version 3.0b](http://files.superrewards.com/SDKs/ios/SuperRewards.framework-3.0b.zip)