Setting iOS custom dimensions

Before custom dimensions will appear in the dashboard, you need to set them for the first time. Use the following code examples to learn how to set custom dimensions for iOS automatically and manually.

Automatic

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   [Localytics addAnalyticsDelegate:self];

   [Localytics autoIntegrate:@"App Key" launchOptions:launchOptions];     // Configure Localytics

   return YES;
}

- (void)localyticsSessionWillOpen:(BOOL)isFirst isUpgrade:(BOOL)isUpgrade isResume:(BOOL)isResume
{
   if (isFirstSession)
   {
      [Localytics setValue:@"Paid" forCustomDimension:0];  // App Type - Unknown / Trial / Paid
      [Localytics setValue:@"Gold" forCustomDimension:1];  // User Status - Gold / Platinum / Diamond
   }
   if (isUpgrade)
   {
      [Localytics setValue:"On" forCustomDimension:2];    // Notifications - On / Off
   }
}
Note: The app delegate must conform to the LLAnalyticsDelegate protocol as follows.
@interface YourAppDelegate : UIResponder <UIApplicationDelegate, LLAnalyticsDelegate>

Manual

With this approach, there are no ‘unknown’ values. Please note that the following values are sample custom dimensions.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   [Localytics integrate:appKey];     // Initialize Localytics
   
   [Localytics addAnalyticsDelegate:self];

   return YES;
}

- (void)localyticsSessionWillOpen:(BOOL)isFirst isUpgrade:(BOOL)isUpgrade isResume:(BOOL)isResume
{
   if (isFirstSession)
   {
      [Localytics setValue:@"Paid" forCustomDimension:0];  // App Type - Unknown / Trial / Paid
      [Localytics setValue:@"Gold" forCustomDimension:1];  // User Status - Gold / Platinum / Diamond
   }
   if (isUpgrade)
   {
      [Localytics setValue:"On" forCustomDimension:2];    // Notifications - On / Off
   }
}