了解如何在行動應用程式中實作Adobe Experience Platform Mobile SDK。
在本課程中,您將:
在行動應用程式實作中,「擴充功能」和「SDK」幾乎可互換。
如果您不熟悉CocoaPods,請查閱該官員 快速入門手冊.
安裝通常是簡單的sudo命令:
sudo gem install cocoapods
安裝CocoaPods後,請開啟Podfile。
更新檔案以包含下列Pod:
pod 'AEPCore', '~> 3'
pod 'AEPEdge', '~> 1'
pod 'AEPUserProfile', '~> 3'
pod 'AEPAssurance', '~> 3'
pod 'AEPServices', '~> 3'
pod 'AEPEdgeConsent', '~> 1'
pod 'AEPLifecycle', '~>3'
pod 'AEPMessaging', '~>1'
pod 'AEPEdgeIdentity', '~>1'
pod 'AEPSignal', '~>3'
AEPMessaging
只有在您計畫使用Adobe Journey Optimizer實作推送訊息時,才為必要。 請閱讀以下教學課程: 使用Adobe Journey Optimizer實作推送訊息 以取得更多資訊。
將變更儲存至您的Podfile後,導覽至專案所在的資料夾並執行 pod install
命令安裝更改。
如果您收到「在專案目錄中找不到Podfile」。 錯誤,您的終端位於錯誤的資料夾中。 導覽至含有您更新之Podfile的資料夾,然後再試一次。
如果您想要升級至最新版本,請執行 pod update
命令。
如果您無法在自己的應用程式中使用CocoaPods,您可以了解其他 支援的實作 GitHub專案中。
若要建置CocoaPods,請開啟 Luma.xcworkspace
,然後選取 產品,後跟 清除建置資料夾.
您可能需要設定 僅構建活動體系結構 to 否. 若要這麼做,請從專案導覽器中選取Pods專案,然後選取 建置設定,並設定 構建活動體系結構 to 否.
您現在可以建置並執行專案。
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 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, 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社群討論貼文