iOS SDK Documentation - RedTroops/IOS-SDK GitHub Wiki

#RedTroops SDK 2.0 for IOS
Requirements: IOS 5.0 +
###Getting Started
RedTroops SDK 2.0 currently features:
Push Notifications.
Send user spent time.
HTML5/Image Popups.
Setting Up RedTroops SDK 2.0 In Your Project
Follow the steps below to get your RedTroops SDK 2.0 running:
- 
Download the SDK from RedTroops' website. 
- 
Drag & Drop downloaded files (RedTroops.a + include) to your project. 
- 
Add following framework: 
- SystemConfiguration.framework
- QuartzCore.framework
- CoreGraphics.framework
- Security.framework
- MobileCoreServices.framework
###Initial Setup
- In your app delegate (AppDelegate.m), import RTSessionManager
    #import "RTSessionManager.h"- In your app delegate (AppDelegate.m), find the method
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:
(NSDictionary*)launchOptionsand add the following line of code
    [[RTSessionManager defaultManager]startSessionWithAPIKey:@“Your API KEY”];- Your API Key: You can find it in RedTroops administration panel. http://developer.dev.redtroops.com/app/index
- In your app delegate (AppDelegate.m), find the method
    - (void)applicationWillTerminate:(UIApplication *)applicationand add the following line of code
    [[RTSessionManager defaultManager] endSession];###Showing Interstitial ad
- Import the following file to your view controller
    #import "RTAdView.h"- Add the following line to your view controller
    RTAdView *adView = [[RTAdView alloc] initWithSize:RTAdPopUp];
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;
    adView.frame = CGRectMake(0,0,screenWidth,screenHeight);
    adView.rootViewController = self;
    [adView loadRequest:[RTAdRequest request]];
    [self.view addSubview:adView];
    [self.view bringSubviewToFront:adView];###Push Notifications
** You can find the guide for generating certificates and integrating them with RedTroops on this link
- Import the following file to your app delegate AppDelegate.m
    #import “RTNotificationManager.h"- In your app delegate (AppDelegate.m), find the method
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptionsand add the following line of code
    if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
      {
	//iOS 8
	[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:
	(UIUserNotificationTypeSound | UIUserNotificationTypeAlert |UIUserNotificationTypeBadge) categories:nil]];
        
        [application registerForRemoteNotifications];
        
      } else {
 
 	//iOS < 8
	[application registerForRemoteNotificationTypes:
	(UIUserNotificationTypeBadge | UIUserNotificationTypeSound |UIUserNotificationTypeAlert)];
      }
    
    
    if ([launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey])
     {
        NSDictionary *payload = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        [[RTNotificationManager defaultManager]startProcessingNotificationPayload:payload];
     }*Note: This code snippet handles notifications for iOS 8 and earlier versions. if you are targeting iOS 8 only, you can add the first part of the first if statement.
- In your app delegate (AppDelegate.m), find the method
    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceTokenand add the following line of code
    [[RTSessionManager defaultManager] registerDeviceToken:deviceToken];- In your app delegate (AppDelegate.m), find the method
    -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfoand add the following line of code
    [[RTNotificationManager defaultManager]startProcessingNotificationPayload:userInfo];If you need any help or for more information, please visit: RedTroops Docs