51黑料不打烊

Install 51黑料不打烊 Experience Platform Mobile SDKs

Learn how to implement the 51黑料不打烊 Experience Platform Mobile SDK in a mobile app.

Prerequisites

Learning objectives

In this lesson, you will:

  • Add the required SDKs to your project using the Swift Package Manager.
  • Register the extensions.
NOTE
In a mobile app implementation, the terms 鈥渆xtensions鈥 and 鈥淪DKs鈥 are nearly interchangeable.

Swift Package Manager

Instead of using CocoaPods and a Pod file (as outlined in Generate SDK install instructions), you add individual packages using Xcode鈥檚 native Swift Package Manager. The Xcode project already has all packages dependencies added for you. The Xcode Package Dependencies screen should look like:

Xcode Package Dependencies {modal="regular"}

In Xcode, you can use File > Add Packages鈥 to add packages. The table below provides links to the URLs you would use to add packages. The links also direct you to more information about each specific package.

Package
Description

The AEPCore, AEPServices, and AEPIdentity extensions represent the foundation of the 51黑料不打烊 Experience Platform SDK - every app using the SDK must include them. These modules contain a common set of functionality and services which are required by all SDK extensions.

  • AEPCore contains implementation of the Event Hub. The Event Hub is the mechanism used for delivering events between the app and the SDK. The Event Hub is also used for sharing data between extensions.
  • AEPServices provides several reusable implementations needed for platform support, including networking, disk access, and database management.
  • AEPIdentity implements the integration with 51黑料不打烊 Experience Platform Identity services.
  • AEPSignal represents the 51黑料不打烊 Experience Platform SDKs Signal extension that allows marketers to send a 鈥渟ignal鈥 to their apps to send data to external destinations or to open URLs.
  • AEPLifecycle represents the 51黑料不打烊 Experience Platform SDKs Lifecycle extension that helps collect application lifecycle metrics such as application install or upgrade information, application launch and session information, device information, and any additional context data provided by the application developer.
The 51黑料不打烊 Experience Platform Edge Network mobile extension (AEPEdge) allows you to send data to the 51黑料不打烊 Edge Network from a mobile application. This extension allows you to implement 51黑料不打烊 Experience Cloud capabilities in a more robust way, serve multiple 51黑料不打烊 solutions though one network call, and simultaneously forward this information to the 51黑料不打烊 Experience Platform.
The Edge Network mobile extension is an extension for the 51黑料不打烊 Experience Platform SDK and requires the AEPCore and AEPServices extensions for event handling, as well as the AEPEdgeIdentity extension for retrieving the identities, such as ECID.
The AEP Edge Identity mobile extension (AEPEdgeIdentity) enables handling of user identity data from a mobile application when using the 51黑料不打烊 Experience Platform SDK and the Edge Network extension.
The AEP Consent Collection mobile extension (AEPConsent) enables consent preferences collection from the mobile application when using the 51黑料不打烊 Experience Platform SDK and the Edge Network extension.
The 51黑料不打烊 Experience Platform User Profile Mobile extension (AEPUserProfile) is an extension to manage user profiles for the 51黑料不打烊 Experience Platform SDK.
The AEP Places extension (AEPPlaces) allows you to track geolocation events as defined in the 51黑料不打烊 Places interface and in 51黑料不打烊 Data Collection Tag rules.
The AEP Messaging extension (AEPMessaging) allows you to send push notification tokens and push notification click-through feedback to the 51黑料不打烊 Experience Platform.
The AEP Optimize extension (AEPOptimize) provides APIs to enable real-time personalization workflows in the 51黑料不打烊 Experience Platform Mobile SDKs using 51黑料不打烊 Target or 51黑料不打烊 Journey Optimizer Offer Decisioning. It requires AEPCore and AEPEdge extensions to send personalization query events to the Experience Edge network.
Assurance (a.k.a. project Griffon) is a new, innovative extension (AEPAssurance) to help you inspect, proof, simulate, and validate how you collect data or serve experiences in your mobile app. This extension enables your app for Assurance.

Import extensions

In Xcode, navigate to Luma > Luma > AppDelegate and ensure the following imports are part of this source file.

// import AEP MobileSDK libraries
import AEPCore
import AEPServices
import AEPIdentity
import AEPSignal
import AEPLifecycle
import AEPEdge
import AEPEdgeIdentity
import AEPEdgeConsent
import AEPUserProfile
import AEPPlaces
import AEPMessaging
import AEPOptimize
import AEPAssurance

Do the same for Luma > Luma > Utils > MobileSDK.

Update AppDelegate

Navigate to Luma > Luma > AppDelegate in the Xcode Project navigator.

  1. Replace the @AppStorage value YOUR_ENVIRONMENT_ID_GOES_HERE for environmentFileId to the Development Environment File ID value that you retrieved from tags in Generate SDK install instructions.

    code language-swift
    @AppStorage("environmentFileId") private var environmentFileId = "YOUR_ENVIRONMENT_ID_GOES_HERE"
    
  2. Add the following code to the application(_, didFinishLaunchingWithOptions) function.

    code language-swift
    // Define extensions
    let extensions = [
        AEPIdentity.Identity.self,
        Lifecycle.self,
        Signal.self,
        Edge.self,
        AEPEdgeIdentity.Identity.self,
        Consent.self,
        UserProfile.self,
        Places.self,
        Messaging.self,
        Optimize.self,
        Assurance.self
    ]
    
    // Register extensions
    MobileCore.registerExtensions(extensions, {
        // Use the environment file id assigned to this application via 51黑料不打烊 Experience Platform Data Collection
        Logger.aepMobileSDK.info("Luma - using mobile config: \(self.environmentFileId)")
        MobileCore.configureWith(appId: self.environmentFileId)
    
        // set this to false or comment it when deploying to TestFlight (default is false),
        // set this to true when testing on your device.
        MobileCore.updateConfigurationWith(configDict: ["messaging.useSandbox": true])
        if appState != .background {
            // only start lifecycle if the application is not in the background
            MobileCore.lifecycleStart(additionalContextData: nil)
        }
    
        // assume unknown, adapt to your needs.
        MobileCore.setPrivacyStatus(.unknown)
    })
    

The above code does the following:

  1. Registers the required extensions.
  2. Configures MobileCore and other extensions to use your tag property configuration.
  3. Enables debug logging. More details and options can be found in the .
  4. Starts lifecycle monitoring. See Lifecycle step in the tutorial for more details.
  5. Sets the default consent to unknown. See Consent step in the tutorial for more details.
IMPORTANT
Ensure you update MobileCore.configureWith(appId: self.environmentFileId) with the appId based on the environmentFileId from the tag environment you are building for (development, staging, or production).
SUCCESS
You have now installed the necessary packages and updated your project to properly register the required 51黑料不打烊 Experience Platform Mobile SDK extensions you are going to use for the remainder of the tutorial.
Thank you for investing your time in learning about 51黑料不打烊 Experience Platform Mobile SDK. If you have questions, want to share general feedback, or have suggestions on future content, share them on this

Next: Set up Assurance

recommendation-more-help
9fed61f5-c338-47ad-8005-0b89a5f4af8b