安装Adobe Experience Platform Mobile SDK

了解如何在移动应用程序中实施Adobe Experience Platform Mobile SDK。

先决条件

学习目标

在本课程中,您将执行以下操作:

  • 使用Swift包管理器将所需的SDK添加到您的项目中。
  • 注册扩展。
NOTE
在移动应用程序实施中,“扩展”和“SDK”这两个术语几乎可以互换。

Swift包管理器

不要使用CocoaPods和Pod文件(如中所述) 生成SDK安装说明),您可使用Xcode的本机Swift包管理器添加单个包。 Xcode项目已经为您添加了所有包依赖项。 Xcode 程序包依赖项 屏幕应如下所示:

Xcode包依赖项 {zoomable="yes"}

在Xcode中,您可以使用 文件 > 添加包…… 以添加包。 下表提供了用于添加包的URL的链接。 这些链接还将引导您了解有关每个特定包的更多信息。

描述
AEP核心

AEPCoreAEPServices、和 AEPIdentity 扩展是Adobe Experience Platform SDK的基础 — 使用SDK的每个应用程序都必须包含这些扩展。 这些模块包含所有SDK扩展所需的一组通用功能和服务。

  • AEPCore 包含事件中心的实施。 事件中心是在应用程序和SDK之间交付事件的机制。 事件中心还用于在扩展之间共享数据。
  • AEPServices 提供平台支持所需的多种可重用的实现,包括网络、磁盘访问和数据库管理。
  • AEPIdentity 实施与Adobe Experience Platform Identity服务的集成。
  • AEPSignal 表示Adobe Experience Platform SDK Signal扩展,该扩展允许营销人员向其应用程序发送“信号”,以将数据发送到外部目标或打开URL。
  • AEPLifecycle 表示Adobe Experience Platform SDK生命周期扩展,该扩展可帮助收集应用程序生命周期量度,例如应用程序安装或升级信息、应用程序启动和会话信息、设备信息以及应用程序开发人员提供的任何其他上下文数据。
AEP Edge
Adobe Experience Platform Edge Network移动扩展(AEPEdge)允许您从移动应用程序向Adobe Edge Network发送数据。 通过此扩展,您可以更稳健地实施Adobe Experience Cloud功能,通过一个网络调用提供多个Adobe解决方案,并同时将此信息转发到Adobe Experience Platform。
Edge Network移动扩展是Adobe Experience Platform SDK的扩展,它需要 AEPCoreAEPServices 事件处理的扩展,以及 AEPEdgeIdentity 用于检索身份(如ECID)的扩展。
AEP Edge标识
AEP Edge Identity Mobile扩展(AEPEdgeIdentity)在使用Adobe Experience Platform SDK和Edge Network扩展时,支持处理来自移动应用程序的用户身份数据。
AEP Edge同意
AEP同意收集移动扩展(AEPConsent)在使用Adobe Experience Platform SDK和Edge Network扩展时,支持从移动应用程序收集同意首选项。
AEP用户配置文件
Adobe Experience Platform用户配置文件移动扩展(AEPUserProfile)是一个扩展,用于管理Adobe Experience Platform SDK的用户配置文件。
AEP Places
AEP Places扩展(AEPPlaces)允许您跟踪Adobe位置界面和Adobe数据收集标记规则中定义的地理位置事件。
AEP消息
AEP消息传送扩展(AEPMessaging)允许您将推送通知令牌和推送通知点进反馈发送到Adobe Experience Platform。
AEP优化
AEP优化扩展(AEPOptimize)提供一些API,以便使用Adobe Target或Adobe Journey OptimizerOffer decisioning在Adobe Experience Platform Mobile SDK中启用实时个性化工作流。 它需要 AEPCoreAEPEdge 用于将个性化查询事件发送到Experience Edge网络的扩展。
AEP保证
Assurance(又称Griffon项目)是一种新颖的扩展(AEPAssurance),以帮助您检查、验证、模拟和验证在移动设备应用程序中收集数据或提供体验的方式。 此扩展可为您的应用程序启用保证。

导入扩展

在Xcode中,导航到 Luma > Luma > AppDelegate 并确保以下导入是此源文件的一部分。

// 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

对执行相同操作 Luma > Luma > Utils > MobileSDK.

更新AppDelegate

导航到 Luma > Luma > AppDelegate 在Xcode项目导航器中。

  1. 替换 @AppStorageYOUR_ENVIRONMENT_ID_GOES_HERE 对象 environmentFileId 到从中的标记检索到的开发环境文件ID值 生成SDK安装说明.

    code language-swift
    @AppStorage("environmentFileId") private var environmentFileId = "YOUR_ENVIRONMENT_ID_GOES_HERE"
    
  2. 将以下代码添加到 application(_, didFinishLaunchingWithOptions) 函数。

    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 Adobe 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)
    })
    

上述代码执行以下操作:

  1. 注册所需的扩展。
  2. 配置MobileCore和其他扩展以使用标记属性配置。
  3. 启用调试日志记录。 欲知更多详情和选项,请参见 Adobe Experience Platform移动SDK文档.
  4. 启动生命周期监控。 请参阅 生命周期 有关更多详细信息,请参阅教程中的步骤。
  5. 将默认同意设置为“未知”。 请参阅 同意 有关更多详细信息,请参阅教程中的步骤。
IMPORTANT
确保更新 MobileCore.configureWith(appId: self.environmentFileId) 使用 appId 基于 environmentFileId 从您为(开发、暂存或生产)构建的标记环境中。
SUCCESS
您现在已安装必要的包并更新了项目,以正确注册您将在本教程的其余部分使用的所需Adobe Experience Platform Mobile SDK扩展。
感谢您投入时间学习Adobe Experience Platform Mobile SDK。 如果您有疑问、希望分享一般反馈或有关于未来内容的建议,请在此共享它们 Experience League社区讨论帖子

下一步: 设置保证

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