安裝 Adobe Experience Platform Mobile SDK tutorial_install_mobile_sdks
了解如何在行動應用程式中實作 Adobe Experience Platform Mobile SDK。
先決條件
學習目標
在本課程中,您將會:
- 將必要的SDK新增至專案。
- 註冊擴充功能。
Swift封裝管理程式
您可以使用Xcode的原生Swift封裝管理員,新增個別封裝,而不使用CocoaPods和Pod檔案(如產生SDK安裝指示中所述)。 Xcode專案已經為您新增了所有套件相依性。 Xcode 封裝相依性 畫面應該如下所示:
在Xcode中,您可以使用 檔案 > 新增封裝…… 來新增封裝。 下表提供您用來新增套件的URL連結。 這些連結也會將您導向每個特定套件的詳細資訊。
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 9-row-2 | |
---|---|
套件 | 說明 |
AEP Core |
|
AEP Edge | Adobe Experience Platform Edge Network行動擴充功能(AEPEdge )可讓您從行動應用程式傳送資料至Adobe Edge Network。 此擴充功能可讓您以更強大的方式實施Adobe Experience Cloud功能、透過單一網路呼叫提供多個Adobe解決方案,並同時將此資訊轉送至Adobe Experience Platform。Edge Network行動擴充功能是Adobe Experience Platform SDK的擴充功能。 擴充功能需要 AEPCore 和AEPServices 擴充功能才能處理事件,也需要AEPEdgeIdentity 擴充功能才能擷取身分(例如ECID)。 |
AEP Edge身分 | Adobe Experience Platform Edge Identity行動擴充功能(AEPEdgeIdentity )可讓您在使用Adobe Experience Platform SDK和Edge Network擴充功能時,處理來自行動應用程式的使用者身分資料。 |
AEP Edge同意 | Adobe Experience Platform同意收集行動擴充功能(AEPConsent )可在使用Adobe Experience Platform SDK和Edge Network擴充功能時,從行動應用程式收集同意偏好設定。 |
AEP使用者設定檔 | Adobe Experience Platform使用者設定檔行動擴充功能(AEPUserProfile )是管理Adobe Experience Platform SDK使用者設定檔的擴充功能。 |
AEP Places | Adobe Experience Platform Places擴充功能(AEPPlaces )可讓您追蹤Adobe Places介面和Adobe資料收集標籤規則中定義的地理位置事件。 |
AEP訊息 | Adobe Experience Platform傳訊擴充功能(AEPMessaging )可讓您將推播通知權杖和推播通知點進意見傳送至Adobe Experience Platform。 |
AEP最佳化 | Adobe Experience Platform Optimize擴充功能(AEPOptimize )提供API,以便使用Adobe Target或Adobe Journey Optimizer Offer Decisioning在Adobe Experience Platform Mobile SDK中啟用即時個人化工作流程。 它需要AEPCore 和AEPEdge 擴充功能,才能將個人化查詢事件傳送至Experience Edge Network。 |
AEP Assurance | Adobe Experience Platform Assurance是Adobe Experience Cloud的產品,可協助您檢查、證明、模擬及驗證如何在行動應用程式中收集資料或提供體驗。 |
匯入擴充功能
在Xcode中開啟範例應用程式 開始 資料夾中的專案。
在Xcode中,導覽至 Luma > Luma > AppDelegate,並確定下列匯入為此來源檔案的一部分。
code language-swift |
---|
|
對 Luma > Luma > Utils > MobileSDK 執行相同操作。
更新AppDelegate
導覽至Xcode專案導覽器中的 Luma > Luma > AppDelegate。
-
將
@AppStorage
的YOUR_ENVIRONMENT_ID_GOES_HERE
值environmentFileId
取代為您從產生SDK安裝指示中的標籤擷取到的環境檔案識別碼值。code language-swift @AppStorage("environmentFileId") private var environmentFileId = "YOUR_ENVIRONMENT_ID_GOES_HERE"
-
將下列程式碼新增至
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) })
上述程式碼會執行下列動作:
- 註冊必要的副檔名。
- 設定MobileCore和其他擴充功能以使用標籤屬性設定。
- 啟用偵錯記錄。 如需詳細資訊和選項,請參閱Adobe Experience Platform Mobile SDK檔案。
- 開始生命週期監視。 如需詳細資訊,請參閱教學課程中的生命週期步驟。
- 將預設同意設定為未知。 如需詳細資訊,請參閱教學課程中的同意步驟。
請確定您根據您正在建置的標籤環境(開發、測試或生產) MobileCore.configureWith(appId: self.environmentFileId)
,使用appId
更新environmentFileId
。
Gradle
您使用產生SDK安裝指示的相依性,使用Gradle與Android Studio的整合來新增個別套件,Android Studio專案已為您新增所有套件相依性。
-
選取
-
選取 Android 檢視。
-
從左窗格選取 Gradle指令碼 > build.gradle.kts (模組:app)。 然後在右窗格中捲動,直到您看到
dependencies
為止。
在Android Studio中,您可以使用 檔案 > 專案結構…… 來新增模組相依性。 選取 相依性,然後使用 模組
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 9-row-2 | |
---|---|
封裝 com.adobe。 marketing.mobile: |
說明 |
核心 |
|
edge | Adobe Experience Platform Edge Network行動擴充功能(AEPEdge )可讓您從行動應用程式傳送資料至Adobe Edge Network。 此擴充功能可讓您以更強大的方式實施Adobe Experience Cloud功能、透過單一網路呼叫提供多個Adobe解決方案,並同時將此資訊轉送至Adobe Experience Platform。Edge Network行動擴充功能是Adobe Experience Platform SDK的擴充功能。 擴充功能需要 Mobile Core 和Services 擴充功能才能處理事件。 和用於擷取身分識別的Identity for Edge Network 延伸模組,例如ECID。 |
edgeidentity | Adobe Experience Platform Edge Identity行動擴充功能可讓您在使用Adobe Experience Platform SDK和Edge Network擴充功能時,處理來自行動應用程式的使用者身分資料。 |
edgeconsent | Adobe Experience Platform同意收集行動擴充功能可讓您在使用Adobe Experience Platform SDK和Edge Network擴充功能時,從行動應用程式收集同意偏好設定。 |
使用者設定檔 | Adobe Experience Platform使用者設定檔行動擴充功能是管理Adobe Experience Platform SDK使用者設定檔的擴充功能。 |
aepplaces | Adobe Places Service是一項地理位置服務,可啟用具位置感知功能的行動應用程式。 使用豐富且簡單易用的SDK介面,搭配有彈性的興趣點資料庫(POI)來瞭解位置環境。 如需詳細資訊,請參閱Places服務檔案。 此服務是Android 2.x Adobe Experience Platform SDK的Places行動擴充功能,需要核心擴充功能來處理事件。 |
傳訊 | Adobe Experience Platform Messaging擴充功能可支援行動應用程式的推播通知、應用程式內訊息和程式碼型體驗。 此擴充功能也可協助您收集使用者推播權杖,並管理與Adobe Experience Platform服務的互動測量。 |
最佳化 | Adobe Experience Platform Optimize擴充功能提供API,以便使用Adobe Target或Adobe Journey Optimizer Offer Decisioning在Adobe Experience Platform SDK中啟用即時個人化工作流程。 此功能取決於行動核心,並需要Edge擴充功能才能將個人化查詢事件傳送至Experience Edge Network。 |
保證 | Assurance (亦即Griffon專案)是Adobe Experience Platform的行動擴充功能,可與Adobe Experience Platform Assurance整合。 擴充功能可協助檢查、證明、模擬及驗證您如何收集行動應用程式中的資料或提供體驗。 此擴充功能需要使用MobileCore。 |
匯入擴充功能
在Android Studio中,導覽至 應用程式 > kotlin+java > com.adobe.luma.tutorial.android > LumaApplication,並確定下列匯入專案是來源檔案的一部分。
code language-kotlin |
---|
|
對 應用程式 > kotlin+java > com.adobe.luma.tutorial.android > 模型 > MobileSDK 執行相同動作。
更新LumaApp
在 Android 檢視中,導覽至Android Studio中的 應用程式 > kotlin+java > com.adobe.luma.tutorial.android > LumaApplication。
-
將
"YOUR_ENVIRONMENT_FILE_ID"
中的private var environmentFileId = "YOUR_ENVIRONMENT_ID_GOES_HERE"
取代為您從產生SDK安裝指示中的標籤擷取到的環境檔案識別碼值。code language-kotlin private var environmentFileId = "YOUR_ENVIRONMENT_ID_GOES_HERE"
-
將下列程式碼新增至
override fun onCreate()
中的class LumaApplication : Application()
函式。code language-kotlin // Define extensions val extensions = listOf( Identity.EXTENSION, Lifecycle.EXTENSION, Signal.EXTENSION, Edge.EXTENSION, Consent.EXTENSION, UserProfile.EXTENSION, Places.EXTENSION, Messaging.EXTENSION, Optimize.EXTENSION, Assurance.EXTENSION ) // Register extensions MobileCore.registerExtensions(extensions) { // Use the environment file id assigned to this application via Adobe Experience Platform Data Collection Log.i("Luma", "Using mobile config: $environmentFileId") MobileCore.configureWithAppID(environmentFileId) // set this to true when testing on your device, default is false. //MobileCore.updateConfiguration(mapOf("messaging.useSandbox" to true)) // assume unknown, adapt to your needs. MobileCore.setPrivacyStatus(MobilePrivacyStatus.UNKNOWN) }
上述程式碼會執行下列動作:
- 註冊必要的副檔名。
- 設定MobileCore和其他擴充功能以使用標籤屬性設定。
- 啟用偵錯記錄。 如需詳細資訊和選項,請參閱Adobe Experience Platform Mobile SDK檔案。
- 開始生命週期監視。 如需詳細資訊,請參閱教學課程中的生命週期步驟。
- 將預設同意設定為未知。 如需詳細資訊,請參閱教學課程中的同意步驟。
請確定您根據您正在建置的標籤環境(開發、測試或生產)中的環境檔案ID,使用MobileCore.configureWith(environmentFileId)
更新environmentFileId
。
下一步: 設定Assurance