iOS SDK Integration

Getting Started with the WhiteMobi iOS SDK

To begin monetizing your application with the WhiteMobi SDK, follow these 2 easy steps:

  1. Add the WhiteMobi SDK to your project
  2. Create WhiteMobi Instance

Before You Start
We support iOS versions 8.4 and up.

Step 1. Add the WhiteMobi SDK to Your Project

Note:
Make sure you have integrated the latest version of our SDK.
If you are upgrading from a previous version of the WhiteMobi SDK, you must completely remove it from your project, otherwise it will cause issues with the update. We also recommend erasing older builds from test devices and making a new build.

Follow these steps to add the WhiteMobi SDK to your project:

  1. Add WhiteMobi Framework
    After you download the SDK; unzip it and add Whitemobi.framework into your Xcode Project.
  2. Adding Required Frameworks
    Go to Targets - Build Phases - Link Binary With Libraries.
    Click ‘+’ to add the following frameworks:

    <UIKit/UIKit.h>
    <Foundation/Foundation.h>
    <AdSupport/AdSupport.h>
    

iOS9 App Transport Security settings

Add in a dictionary called ‘NSAppTransportSecurity‘. Make sure you add this dictionary on the ‘Top Level Key‘. Inside this dictionary, add a Boolean called ‘NSAllowsArbitraryLoads‘ and set it to YES.

Or open Info.plist as Source Code and add

<key>NSAppTransportSecurity</key>
<dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

Note:
Make sure that your Info.plist does not contain any other exceptions besides ‘NSAllowsArbitraryLoads‘, as this might create a conflict.

Step 2. Create WhiteMobi Instance

Follow these steps to create a WhiteMobi Instance

Import the following file:

#import <Whitemobi/Whitemobi.h>

Create a WhiteMobi instance by calling the following method on your application start:

//Client-to-Server Mode
[[WMManager sharedManager] initWithKey:@"APPLICATION_KEY" forUser:@"USER_ID"];
[[WMManager sharedManager] addCallbackListener];

Note: To receive user rewards in client-to-server mode, you can register to the delegate.

      [[WMManager sharedManager] setDelegate:self];
//Server-to-Server Mode
[[WMManager sharedManager] initWithKey:@"APPLICATION_KEY"];

Done!

You are now ready to start working with WhiteMobi SDK.

Offerwall Integration for iOS

Get up and running with the Offerwall Ad Unit in 4 easy steps:

  1. Implement the Delegate (in client-to-server mode)
  2. Initialize the Offerwall Unit
  3. Present the Offerwall
  4. Reward the User (in client-to-server mode)

Before You Start
Make sure that you have correctly integrated the WhiteMobi SDK into your application.

Step 1. Implement the Delegate (in client-to-server mode)

The WhiteMobi SDK fires event to inform you of Offerwall Activity and completions so you’ll know when to reward your users.

To receive these events, register to the delegate:

[[WMManager sharedManager] setDelegate:self];
/*!
* @brief Use this method if you choose client-to-server mode and need to received
*        award for completed offerwall task.
*/
[[WMManager sharedManager] addCallbackListener]; 

Note: Please do not assume the callbacks are always running on the main thread. Any UI interaction or updates resulting from WhiteMobi callbacks need to be passed on to the main thread before execution.

The SDK will notify your delegate about event:

/*!
* @brief Delegate method that you'd use if you select client-to-server mode
*        to retrieve reward for offerwall task.
* @parameter offerResponse NSDictionary that contains response from server.
*/
-(void)receiveCoinsForOffer:(NSDictionary *)offerResponse;

Step 2. Initialize the Offerwall Unit

Once the Offerwall Ad Unit is initialized, you will able to call functions on it. We recommend initializing the Offerwall on application launch.

//Client-to-Server Mode
[[WMManager sharedManager] initWithKey:@"APPLICATION_KEY" forUser:@"USER_ID"];
[[WMManager sharedManager] addCallbackListener];

Note: To receive user rewards in client-to-server mode, you should register to the delegate.

[[WMManager sharedManager] setDelegate:self];
//Server-to-Server Mode
[[WMManager sharedManager] initWithKey:@"APPLICATION_KEY"];

Note:
applicationKey You're private application key.
userID You're inner userID in application. We support NSString from 1 to 64 characters.

Step 3. Present the Offerwall

When you want to serve the Offerwall (typically after a user clicks on some in-app button), call that method on your WhiteMobi instance:

/*!
* Show an offerwall
* @param viewController Current UIViewController which used for calling offerwall
*/
-(void)showMessageInViewController:(UIViewController *)viewController;

Note: f you’d like to use client-side callbacks, make sure to follow Step 1 of the Automatic Client-Side Events below before you call showMessageInViewController

Step 4. Reward the User

WhiteMobi supports two methods to reward your users. Select one of the following:

Client-to-Server Callbacks

You can receive client-side events automatically within your application by registering to the Offerwall delegate and setting the use of client-side callbacks. Setting automatic client-side callbacks will make sure that you’re notified about the user’s credit status at specific points in the Offerwall’s lifecycle. To do so:

[[WMManager sharedManager] addCallbackListener];

Once there is a completion event from the user the WhiteMobi SDK will fire

-(void)receiveCoinsForOffer:(NSDictionary *)offerResponse

event informing you of the completion.

Note: To receive user rewards in client-to-server mode, you should register to the delegate.

[[WMManager sharedManager] setDelegate:self];

Server-to-Server Callbacks

If you turn on server-to-server callbacks in addition to the client-side callbacks, remember not to reward the user more than once for the same completion.
WhiteMobi reward-based ad units support server-to-server events to notify you of rewards that must be granted to your users after successful Offerwall ad completion events.

Done!
You are now all set to deliver Offerwall Ad Units in your application.

Tip: If this is a new integration, your application in your WhiteMobi account will by default be in ‘Test Mode‘. In addition, the first ad you will see will be a WhiteMobi test campaign.