Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Latest commit

 

History

History
352 lines (225 loc) · 12.2 KB

sdk-methods.md

File metadata and controls

352 lines (225 loc) · 12.2 KB

Configuration methods

Here is a list of methods that are provided by the iOS library.

The SDK currently has support for multiple Adobe Experience Cloud Solutions, including Analytics, Target, Audience Manager, and the Adobe Experience Platform Identity Service.

  • setAppExtensionType

    Configures the Adobe Mobile SDK setting to determine what kind of extension is currently being executed.

    Set to one of the following values:

    • ADBMobileAppExtensionTypeRegular - extension is bundled with a containing app.
    • ADBMobileAppExtensionTypeStandAlone - extension is not bundled with a containing app.

    Tip: This method should only be used if your app has an extension or is a stand-alone extension. For more information, see ADBMobileAppExtensionType below.

    • Here is the syntax for this method:

      + (void) setAppExtensionType:(ADBMobileAppExtensionType)type;
    • Here is the code sample for this method:

      [ADBMobile setAppExtensionType:ADBMobileAppExtensionTypeStandAlone]; 
  • version

    Returns the current version of the Adobe Mobile library.

    • Here is the syntax for this method:

      +(NSString*) version;
    • Here is the code sample for this method:

      NSString*libraryVersion = [ADBMobileversion];
  • privacyStatus

    Returns the enum representation of the privacy status for current user:

    • ADBMobilePrivacyStatusOptIn - hits are sent immediately.

    • ADBMobilePrivacyStatusOptOut - hits are discarded.

    • ADBMobilePrivacyStatusUnknown - If offline tracking is enabled, hits are saved until the privacy status changes to opt-in (then hits are sent) or opt-out (then hits are discarded). If offline tracking is not enabled, hits are discarded until the privacy status changes to opt in. The default value is set in the ADBMobileConfig.json file.

    • Here is the syntax for this method:

      + (ADBMobilePrivacyStatus) privacyStatus;
    • Here is the code sample for this method:

      ADBMobilePrivacyStatus privacyStatus = [ADBMobileprivacyStatus];
  • setPrivacyStatus

    Sets the privacy status for the current user to status.

    Set to one of the following values:

    • ADBMobilePrivacyStatusOptIn - hits are sent immediately.

    • ADBMobilePrivacyStatusOptOut - hits are discarded.

    • ADBMobilePrivacyStatusUnknown - If offline tracking is enabled, hits are saved until the privacy status changes to opt-in (then hits are sent) or opt-out (then hits are discarded). If offline tracking is not enabled, hits are discarded until the privacy status changes to opt in.

    • Here is the syntax for this method:

      + (void) setPrivacyStatus:(ADBMobilePrivacyStatus)status;
    • Here is the code sample for this method:

      [ADBMobile setPrivacyStatus:ADBMobilePrivacyStatusOptIn];
  • lifetimeValue

    Returns the lifetime value of the current user. The default value is 0.

    • Here is the syntax for this method:

      + (NSDecimalNumber *) lifetimeValue;
    • Here is the code sample for this method:

      NSDecimalNumber *lifeValue = [ADBMobile lifetimeValue];
  • trackingIdentifier

    Returns the automatically generated visitor identifier. This is an app-specific unique visitor ID that is generated by Adobe’s servers. If Adobe's servers cannot be reached at the time of generation, then the ID is generated using Apple's CFUUID. The value is generated at the initial launch and is stored and used from that point forward. This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall.

    Tip: If your app upgrades from the Experience Cloud 3.x to the 4.x SDK, the previous custom or automatically generated visitor ID is retrieved and stored as the custom user identifier. For more information, see the userIdentifier row below. This preserves visitor data between SDK upgrades. For new installations on the 4.x SDK, the user identifier is nil and tracking identifier is used.

    • Here is the syntax for this method:

      + (NSString *) trackingIdentifier;
    • Here is the code sample for this method:

      NSString *tid = [ADBMobile trackingIdentifier];
  • userIdentifier

    If a custom identifier has been set, the user identifier is returned. If a custom identifier is not set, nil is returned. The default value is nil.

    Tip: If your app upgrades from the Experience Cloud 3.x to 4.x SDK, the previous custom or automatically generated visitor ID is retrieved and stored as the custom user identifier. This preserves visitor data between upgrades of the SDK.

    For new installations on the 4.x SDK, the user identifier is nil until set.

    • Here is the syntax for this method:

      +(NSString *) userIdentifier;
    • Here is the code sample for this method:

      NSString *uid = [ADBMobileuserIdentifier];
  • setUserIdentifier

    Sets the user identifier to identifier.

    • Here is the syntax for this method:

      +(void)setUserIdentifier:(NSString*)identifier;
    • Here is the code sample for this method:

      [ADBMobile setUserIdentifier:@"billybob"]; 
  • debugLogging

    Returns the current debug logging preference. The default value is NO.

    • Here is the syntax for this method:

      + (BOOL) debugLogging;
    • Here is the code sample for this method:

      BOOL debugging = [ADBMobile debugLogging];
  • setDebugLogging

    Sets the debug logging preference to debug.

    • Here is the syntax for this method:

      + (void) setDebugLogging:(BOOL)debug;
    • Here is the code sample for this method:

      [ADBMobile setDebugLogging:YES];
  • keepLifecycleSessionAlive

    Indicates to the SDK that your next resume from background should not start a new session, regardless of the value of lifecycle session timeout in your config file.

    Tip: This method is intended to be used for apps that register for notifications while in background and should only be called from the code that runs while your app is in the background.

    • Here is the syntax for this method:

      + (void) keepLifecycleSessionAlive;
    • Here is the code sample for this method:

      [ADBMobile keepLifecycleSessionAlive]; 
  • collectLifecycleData

    Indicates to the SDK that lifecycle data should be collected for use across all solutions in the SDK. For more information, see Lifecycle Metrics.

    Tip: The preferred location to invoke this method is in application:didFinishLaunchingWithOptions:.

    • Here is the syntax for this method:

      + (void) collectLifecycleData;
    • Here is the code sample for this method:

      [ADBMobile collectLifecycleData];
  • collectLifecycleDataWithAdditionalData:

    Allows you to pass in additional data when collecting lifecycle metrics.

    This method must be called from the entry point of your app. Where applicable, this may include one or both of the methods application:didFinishLaunchingWithOptions: and/or applicationWillEnterForeground: in your AppDelegate class.

    Important: Data that is passed to the SDK via collectLifecycleDataWithAdditionalData: will be persisted by the SDK in NSUserDefaults. The SDK will strip values in the NSDictionary parameter that are not of type NSString or NSNumber. To use collectLifecycleDataWithAdditionalData:, you must have SDK version 4.4 or later.

    • Here is the syntax for this method:

      + (void) collectLifecycleDataWithAdditionalData:(nullableNSDictionary*)data; 
    • Here is the code sample for this method:

      [ADBMobile collectLifecycleDataWithAdditionalData:@{@"entryType":@"appShortcutIcon"}]; 
  • pauseCollectingLifecycleData

    Use this API to pause the collection of lifecycle data. For more information, see Lifecycle Metrics.

    Important: In the applicationDidEnterBackground delegate method, you must first call the pauseCollectingLifecycleData method.

    The API is provided to mitigate the issue on iPhone7/7s or older devices with iOS 13 where the session length metric became abnormal. This was due to some unknown changes that have occurred in iOS 13, where iOS does not leave enough time for the background task to finish when you backgroud the app.

    • Here is the syntax for this method:

      + (void) pauseCollectingLifecycleData;
    • Here is the code sample for this method:

      - (void)applicationDidEnterBackground:(UIApplication *)application{
          // manually stop the lifecycle of SDK
          // important: do NOT call any track state or track action after this line
          [ADBMobile pauseCollectingLifecycleData];   
      
      
          // the following code is optional, may help to mitigate the issue a bit more. If you have other logic to run here that probably takes more than 10ms, then there is no need to add this line of code.
          [NSThread sleepForTimeInterval:0.01];
      
      
          // app's code to handle applicationDidEnterBackground
      }
  • overrideConfigPath

    Lets you load a different ADBMobile JSON config file when the application starts. The different configuration is used until the application is closed.

    Important: To use overrideConfigPath, you must have SDK version 4.2 or later.

    • Here is the syntax for this method:

       + (void) overrideConfigPath: (nullableNSString *) path;
    • Here is the code sample for this method:

      NSString *filePath = [[NSBundle mainBundle] pathForResource:@"ExampleJSONFile" ofType:@"json"]; 
      [ADBMobile overrideConfigPath:filePath];
  • setPushIdentifier

    Sets the device token for push notifications.

    Important: This method should only be used in the application:didRegisterForRemoteNotificationsWithDeviceToken: method.

    • Here is the syntax for this method:

      + (void) setPushIdentifier:(NSData *)deviceToken;
    • Here is the code sample for this method:

      - (void) application:(UIApplication *) application  didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
      [ADBMobile setPushIdentifier:deviceToken];  
      }
  • setAdvertisingIdentifier

    Sets the IDFA in the SDK. If the IDFA has been set in the SDK, the IDFA will be sent in lifecycle. It can also be accessed in Signals (Postbacks).

    Tip: Retrieve the IDFA from Apple APIs only if you are using an ad service. If you retrieve IDFA, and are not using it properly, your app might be rejected.

    If your application requires IDFA, check Apple’s documentation for inquiring the user’s preferences on Ad Tracking and retrieving the IDFA value.

    For iOS 14+ the new App Tracking Transparency framework needs to be implemented in order to successfully retrieve the IDFA value.

    • Here is the syntax for this method:

      +(void) setAdvertisingIdentifier:(NSString*)identifier;
    • Here is the code sample for this method:

      NSString *idfa = // retrieve IDFA using AdSupport (before iOS 14.0) and/or AppTrackingTransparency (iOS 14.0+)
      [ADBMobile setAdvertisingIdentifier:idfa]; 

ADBMobileAppExtensionType enum

/** 
 * @brief An enum type. 
 * The possible types of app extension you might use 
 * @see setAppExtensionType 
 */ 
typedef NS_ENUM(NSUInteger, ADBMobileAppExtensionType) { 
    ADBMobileAppExtensionTypeRegular = 0, /*!< Enum value ADBMobileAppExtensionTypeRegular. */ 
    ADBMobileAppExtensionTypeStandAlone = 1 /*!< Enum value ADBMobileAppExtensionTypeStandAlone. */ 
};