1. Home
  2. Integrations
  3. iOS Native Events Setup Guide
  4. Gaming Applications – iOS

Gaming Applications – iOS

We have provided a list of Events with their example usage that can be integrated for Gaming Applications. Please find them below:

Note: Please ensure to include the MTraction header file (as shown below) in the class of your project from where the in App event methods have to be invoked.

#import <mTraction/MTraction.h>

1. Purchase Event

This is used to track the successful Purchase event in your Game.

You will need to call the below method to track the In-App Purchase event in your Application.

[[MTraction mTractionManager] trackPurchase:purchase];
// Product List Array Definition
NSMutableArray *productList=[[NSMutableArray alloc] init];

// Product Constructor Call
-(id)initWithProductIdentifier:(NSString*)identifier productName:(NSString*)productName price:(float)price quantity:(short)quantity;

  • Mandatory parameters (Product):  
    • Product Identifier – Unique Product Identifier
    • Product Name – Name of the Product
    • Price – Price of the Product
    • Quantity – Quantity of the Product being Purchased
  • Optional parameters (Product): 
    • Brand – Brand Name of the Product
    • Product Discount – Discount applied for the Product
    • Category – Product Category
// Adding the product to the Product List
[productList addObject:product1];

// Purchase Constructor Call
-(void)trackPurchase:(Purchase*) purchase;

  • Mandatory parameters (Purchase):  
    • User Id – Unique User Identifier
    • Revenue – Total Revenue generated from this Purchase event
    • Payment ModeCREDIT_CARD or DEBIT_CARD or NET_BANKING or GIFT_CARD or PAYMENT_WALLET
    • Transaction Id – Unique Purchase Transaction Identifier
    • Purchase FrequencyONCE or RECURRING representing One Time Payment or Subscription based Payment respectively
    • Product List – Array of the list of products purchased
    • Locale – Currency code used for this event.

      NOTE: For passing custom currency code, Follow the sample below: 

      // For Custom Currency Code
      NSLocale *currencyCode = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] ;
      
  • Optional parameters (Purchase): 
    • Loyalty – Loyalty points applied on the Purchase
    • Overall Discount – Discount applied for the Purchase
    • Service Charge – Service Charge applied for the Purchase
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
#import <CoreLocation/CoreLocation.h>
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
  NSLog(@"didUpdateToLocation: %@", newLocation);
  CLLocation *currentLocation = newLocation;
  if (currentLocation != nil) 
  {
    double longitude = currentLocation.coordinate.longitude;
    double latitude = currentLocation.coordinate.latitude;
  }
}

// Default Currency Code from the local instance
NSLocale *currencyCode = [NSLocale currentLocale];

// Product List Array Definition
NSMutableArray *productList=[[NSMutableArray alloc] init];

// Example Product Constructor Call with the mandatory parameters
Product *product1 = [[Product alloc]initWithProductIdentifier:@"12345" productName:@"Gold Coins" price:29.99 quantity:5];

// Examples for other parameters passed for the Product Class (These are optional)
  [product1 setBrand:@"Game Credits - Coins"];
  [product1 setProductDiscount:5.00];
  [product1 setCategory:@"Games"];

// Adding the product to the Product List
[productList addObject:product1];

// Example Purchase Constructor Call with the mandatory parameters
Purchase *purchase = [[Purchase alloc] initWithPurchaseUserId:@"123" revenue:24.65 currency:currencyCode transactionId:@"1000123" paymentMode:DEBIT_CARD frequencyMode:ONCE ProductList:productList];

// Examples for other parameters passed for the Purchase Class (These are optional)
  [purchase setLoyalty:150.00];
  [purchase setOverallDiscount:5.00];
  [purchase setServiceCharge:4.99];
  [purchase setLocationLatitude:latitude longitude:longitude];

// trackPurchase method call
[[MTraction mTractionManager] trackPurchase:purchase];

2. Paid Subscription Deactivated Event

This is used to track when the Player has unsubscribed from any of the services of the Game.

You will need to call the below method to track the Subscription Deactivated event in your Application.

[[MTraction mTractionManager]trackPaidSubscriptionDeactivated:paidSubscriptionDeactivated];
-(void)trackPaidSubscriptionDeactivated:(PaidSubscriptionDeactivated*) paidSubscriptionDeactivated;

  • Mandatory parameters (Paid Subscription Deactivated):  
    • User Id – Unique User Identifier
  • Optional parameters (Paid Subscription Deactivated):  
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude & Latitude code (Long / Lat is optional)
#import <CoreLocation/CoreLocation.h>
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
  NSLog(@"didUpdateToLocation: %@", newLocation);
  CLLocation *currentLocation = newLocation;
  if (currentLocation != nil) 
  {
    double longitude = currentLocation.coordinate.longitude;
    double latitude = currentLocation.coordinate.latitude;
  }
}

// Example Constructor call with User ID (User ID is mandatory)
PaidSubscriptionDeactivated *paidSubscriptionDeactivated = [[PaidSubscriptionDeactivated alloc]initWithPaidSubscriptionDeactivatedUserID:@"123"];

// Examples for other parameters passed with the event (These are optional)
  [paidSubscriptionDeactivated setPageName:@"My Account"];
  [paidSubscriptionDeactivated setLocationLatitude:latitude longitude:longitude];

// trackPaidSubscriptionDeactivated method call
mTractionManager]trackPaidSubscriptionDeactivated:paidSubscriptionDeactivated];

3. Level Achieved Event

This is used to track Player’s progress in the game when he has successfully completed a level.

You will need to call the below method to track the Level Achieved Event in your Application.

[[MTraction mTractionManager]trackLevelAchieved:levelAchieved];
-(void)trackLevelAchieved:(LevelAchieved*) levelAchieved;

  • Mandatory parameters (Level Achieved):  
    • User Id – Unique User Identifier
    • Level – Level Reached by the Player
    • Score – Score accumulated by the Player
  • Optional parameters (Level Achieved):  
    • Rank – Player’s Rank

Sample Code

// Example Constructor Call with the mandatory parameters
LevelAchieved *levelAchieved = [[LevelAchieved alloc]initWithLevelAchievedUserID:@"123" Level:5 Score:4650];

// Examples for other parameters passed with the event (These are optional)
[levelAchieved setRank:5];

// trackLevelAchieved method call
[[MTraction mTractionManager]trackLevelAchieved:levelAchieved];

4. Achievement Unlocked Event

This is used to track the Game Player’s progress when he has completed any milestones to move to the next level of the game.

You will need to call the below method to track the Achievement Unlocked event in your Application.

[[MTraction mTractionManager]trackAchievementUnlocked:achievementUnlocked];
-(void)trackAchievementUnlocked:(AchievementUnlocked*) achievementUnlocked;

  • Mandatory parameters (Achievement Unlocked Event):  
    • User Id – Unique User Identifier
    • Identifier – Unique Identifier of the Level reached by the Player
  • Optional parameters (Achievement Unlocked Event): 
    • Description – Details about the Achievement
    • Category – Category of the Achievement

Sample Code

// Example Constructor Call with the mandatory parameters
AchievementUnlocked *achievementUnlocked = [[AchievementUnlocked alloc]initWithAchievementUnlockedUserID:@"123" Identifier:@"L10"];

// Examples for other parameters passed with the event (These are optional)
  [achievementUnlocked setDescription:@"Storm Trooper"];
  [achievementUnlocked setCategory:@"Novice"];

// trackAchievmentUnlocked method call
[[MTraction mTractionManager]trackAchievementUnlocked:achievementUnlocked];

5. Tutorial Completed Event

This is used to track the event triggered when the Player has completed any tutorials in the Game.

You will need to call the below method to track the Tutorial Completed event in your Application.

[[MTraction mTractionManager]trackTutorialCompleted:tutorialCompleted];
-(void)trackTutorialCompleted:(TutorialCompleted*) tutorialCompleted;

  • Mandatory parameters (Tutorial Completed):  
    • User Id – Unique User Identifier
    • Success FlagTRUE OR FALSE based on the successful evaluation (if available) of the tutorial in the Game.
    • Identifier – Unique Tutorial Identifier

Sample Code

// Example Product Constructor Call with the mandatory parameters
TutorialCompleted *tutorialCompleted = [[TutorialCompleted alloc]initWithTutorialCompletedUserID:@"123" SuccessFlag:True Identifier:@"10008"];

// trackTutorialCompleted method call
[[MTraction mTractionManager]trackTutorialCompleted:tutorialCompleted];
Was this article helpful to you? Yes No

How can we help?