iOS SDK Documentation - RedTroops/IOS-SDK GitHub Wiki

RedTroops

#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:

  1. Download the SDK from RedTroops' website.

  2. Drag & Drop downloaded files (RedTroops.a + include) to your project.

  3. Add following framework:

  • SystemConfiguration.framework
  • QuartzCore.framework
  • CoreGraphics.framework
  • Security.framework
  • MobileCoreServices.framework

###Initial Setup

  1. In your app delegate (AppDelegate.m), import RTSessionManager
    #import "RTSessionManager.h"
  1. In your app delegate (AppDelegate.m), find the method
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:
(NSDictionary*)launchOptions

and add the following line of code

    [[RTSessionManager defaultManager]startSessionWithAPIKey:@“Your API KEY”];
  1. In your app delegate (AppDelegate.m), find the method
    - (void)applicationWillTerminate:(UIApplication *)application

and add the following line of code

    [[RTSessionManager defaultManager] endSession];

###Showing Interstitial ad

  1. Import the following file to your view controller
    #import "RTAdView.h"
  1. 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

  1. Import the following file to your app delegate AppDelegate.m
    #import “RTNotificationManager.h"
  1. In your app delegate (AppDelegate.m), find the method
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

and 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.

  1. In your app delegate (AppDelegate.m), find the method
    -(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

and add the following line of code

    [[RTSessionManager defaultManager] registerDeviceToken:deviceToken];
  1. In your app delegate (AppDelegate.m), find the method
    -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

and add the following line of code

    [[RTNotificationManager defaultManager]startProcessingNotificationPayload:userInfo];

If you need any help or for more information, please visit: RedTroops Docs

⚠️ **GitHub.com Fallback** ⚠️