로딩중입니다
Client Reward Integration : iOS
4/29/2016 5:06:48 PM

IGAW Reward Server Integration: Client Type

In case the internal server to receive callbacks from the IGAW reward server is difficult to set up, the additional client integration can be achieved to treat reward. 



Set Reward Server Integration Method

Edit (*)reward server integration method to handle reward callback through client.

Find IgaworksCore reset API at application: didFinishLaunchingWithOptions: in AppDelegate.m and switch useIgaworksRewardServer parameter to YES.

#import "AppDelegate.h"
#import <IgaworksCore/IgaworksCore.h>
 
@implementation AppDelegate
 
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{	
	[IgaworksCore igaworksCoreWithAppKey:@"YOUR_APP_KEY" andHashKey:@"YOUR_HASH_KEY"];
	[IgaworksCore shared].useIgaworksRewardServer = YES;
	[IgaworksCore shared].clientRewardDelegate = self;
	return YES;
}

+ (*)Reward server integration method: Required when you need to integrate reward pay service. Use useIgaworksRewardServer parameter to setup. 

  • NO : Use your own callback server.
  • YES : Use IGAWorks reward server.



Register and Implement Reward Delegate

Register and implement delegate in order to receive reward information from IGAW reward server.


Import IgaworksAD.h and add IgaworksADClientRewardDelegate to interface.

#import <IgaworksCore/IgaworksCore.h>
#import <AdPopcornOfferwall/AdPopcornOfferwall.h>
#import <AdPopcornOfferwall/RewardInfo.h>
 
@interface ViewController() <IgaworksADClientRewardDelegate>
@end
 
@implementation AppDelegate
@end 

+ RewardInfo.h is header for receiving and handling NSArray type reward information.


View and Pay Reward Information

Untreated reward information from IGAW reward server transferred to onRewardRequestResult: withMessage: items:  delegate.

Reward information transfers to defined model type (NSArray *)items parameter at RewardInfo.h 에and information included in NSArray are these.

  1. items[i].campaignKey : Campaign key user completed.
  2. items[i].campaignName : Campaign name user completed.
  3. items[i].RTID : Completed transaction ID.
  4. items[i].quantity : Quantity of cyber money users have to receive.

Call didGiveRewardItemWithRewardKey API at AdPOPcornOfferwall.h to transfer the information to IGAW reward server.

-(void)onRewardRequestResult:(BOOL)isSuccess withMessage:(NSString *)message items:(NSArray *)items{
    
    for (RewardInfo *item in items) {
	    
        NSString *campaignKey = item.campaignKey;
        NSString *campaignName = item.campaignName;
        NSString *rewardKey = item.RTID;
        NSUInteger quantity = item.quantity;
        		
	//extract RTID from items parameter. 
	[AdPopcornOfferwall didGiveRewardItemWithRewardKey:item.RTID];
    }    
}


See the reward process result

The result of didGiveRewardItemWithRewardKey API will transfer to onRewardCompleteResult: withMessage: resultCode: withCompletedRewardKey: delegate.

Reward payment is processed after getting the result.

  • isSuccess : Reward process result.
  • message : Reward process result message.
  • resultCode : Reward result code.(Check the table below for result code). 
  • completedRewardKey : Payment completed RTID


- (void)onRewardCompleteResult:(BOOL)isSuccess withMessage:(NSString *)message resultCode:(NSUInteger)resultCode withCompletedRewardKey:(NSString *)completedRewardKey {
  // Give reward to user when RTID processing result sent via didGiveRewardItemWithRewardKey API is "Succeed" }



Result Code Definition

Definition of result code transferred to delegate.

CodeDescription
1Succeed
100Error when tried to finish
200Unknown error (Exception)
1400Wrong app key
1410Wrong reward type setting
3000Wrong hash key



Integration Test

After performing and completing the test ad using the test devices at AdPOPcorn Management page [OfferWall Management > QA and Optimization > Test Device Setting], Integration is completed as you see the reward successfully collected.