了解如何在移动应用程序中实施Adobe Experience Platform Mobile SDK。
在本课程中,您将:
在移动设备应用程序实施中,术语“扩展”和“SDK”几乎可以互换。
如果你不熟悉可可豆荚,请查阅 入门指南.
安装通常是一个简单的sudo命令:
$ sudo gem install cocoapods
安装CocoaPods后,打开PodFile:
更新文件以包含以下Pod:
pod 'AEPCore', '~> 3'
pod 'AEPEdge', '~> 1'
pod 'AEPUserProfile', '~> 3'
pod 'AEPAssurance', '~> 3'
pod 'AEPServices', '~> 3'
pod 'AEPIdentity', '~> 3'
pod 'AEPEdgeConsent', '~> 1'
pod 'AEPLifecycle', '~>3'
pod 'AEPMessaging', '~>1'
pod 'AEPEdgeIdentity', '~>1'
pod 'AEPSignal', '~>3'
AEPMessaging
仅当您计划按照所述通过Adobe Journey Optimizer实施推送消息时,才需要使用 此处.
保存Podfile。
通过运行以下命令,导航到项目所在的文件夹: pod install
您应会获得如下所示的输出:
如果收到错误“在项目目录中未找到Podfile”。 那么你的终端在错误的文件夹中。 导航到包含您更新的Podfile的文件夹,然后重试。
如果要升级到最新的次版本,请使用命令:
pod update
如果你无法在自己的应用程序中使用CocoaPods,你可以了解其他 支持的实施 在github项目中。
Open Luma.xcworkspace
.
从Xcode菜单中,选择 产品>清除生成文件夹.
您可能需要将“仅构建活动架构”设置为“否”。
生成并运行。
Luma项目是在M1芯片组上使用Xcode v12.5构建的,并在iOS模拟器上运行。 如果您使用的是其他设置,则可能必须更改内部版本设置才能反映您的架构。
如果生成失败,请尝试还原 构建活动架构 > 调试 设置回 是.
在创作本教程时使用了模拟器配置“iPod touch(第7代)”。
在 .swift
,请添加以下导入。 首先,将添加到 AppDelegate.swift
.
import AEPUserProfile
import AEPAssurance
import AEPEdge
import AEPCore
import AEPEdgeIdentity
import AEPEdgeConsent
import AEPIdentity
import AEPLifecycle
import AEPMessaging //Optional, used for AJO push messaging
import AEPSignal
import AEPServices
在 AppDelegate.swift
文件中,将以下代码添加到 didFinishLaunchingWithOptions
. 将currentAppId替换为您从 上一课.
let currentAppId = "b5cbd1a1220e/bae66382cce8/launch-88492c6dcb6e-development"
let extensions = [Edge.self, Assurance.self, Lifecycle.self, UserProfile.self, Consent.self, AEPEdgeIdentity.Identity.self, AEPIdentity.Identity.self, Messaging.self]
MobileCore.setLogLevel(.trace)
MobileCore.registerExtensions(extensions, {
MobileCore.configureWith(appId: currentAppId)
})
Messaging.self
仅当您计划按照所述通过Adobe Journey Optimizer实施推送消息时,才需要使用 此处.
上述代码会执行以下操作:
在生产应用程序中,您必须根据当前环境(dev/stag/prod)切换AppId。
下一个: 设置保证
感谢您花时间了解Adobe Experience Platform Mobile SDK。 如果您有任何疑问、想要分享一般反馈或对未来内容提出建议,请就此分享 Experience League社区讨论帖子