以最佳化SDK取代SDK

瞭解如何以行動實施中的最佳化SDK取代Adobe Target SDK。 基本取代包含下列步驟:

  • 更新您Podfile或build.gradle檔案中的相依性
  • 更新匯入
  • 更新應用程式程式碼
INFO
在Adobe Experience Platform Mobile SDK生態系統內,擴充功能會由匯入應用程式(名稱可能不同)的SDK實作:
  • 目標SDK ​實作​ Adobe Target擴充功能
  • 最佳化SDK ​實作​ Offer Decisioning和Target擴充功能

更新相依性

Android範例
tabs
最佳化SDK

移轉後的build.gradle相依性

code language-java
implementation platform('com.adobe.marketing.mobile:sdk-bom:3.+')
implementation 'com.adobe.marketing.mobile:core'
implementation 'com.adobe.marketing.mobile:edgeidentity'
implementation 'com.adobe.marketing.mobile:edge'
implementation 'com.adobe.marketing.mobile:optimize'
目標SDK

移轉前build.gradle個相依性

code language-java
implementation platform('com.adobe.marketing.mobile:sdk-bom:3.+')
implementation 'com.adobe.marketing.mobile:analytics'
implementation 'com.adobe.marketing.mobile:target'
implementation 'com.adobe.marketing.mobile:core'
implementation 'com.adobe.marketing.mobile:identity'
implementation 'com.adobe.marketing.mobile:lifecycle'
implementation 'com.adobe.marketing.mobile:signal'
implementation 'com.adobe.marketing.mobile:userprofile'
iOS範例
tabs
最佳化SDK

移轉後的Podfile相依性

code language-swift
use_frameworks!
target 'YourAppTarget' do
    pod 'AEPCore', '~> 5.0'
    pod 'AEPEdge', '~> 5.0'
    pod 'AEPEdgeIdentity', '~> 5.0'
    pod 'AEPOptimize', '~> 5.0'
end
目標SDK

移轉前Podfile個相依性

code language-swift
use_frameworks!
pod 'AEPAnalytics', '~> 5.0'
pod 'AEPTarget', '~> 5.0'
pod 'AEPCore', '~> 5.0'
pod 'AEPIdentity', '~> 5.0'
pod 'AEPSignal', '~>5.0'
pod 'AEPLifecycle', '~>5.0'
pod 'AEPUserProfile', '~> 5.0'

更新匯入和程式碼

Android範例
tabs
最佳化SDK

移轉後的Java初始化程式碼

code language-java
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.edge.identity.Identity;
import com.adobe.marketing.mobile.optimize.Optimize;
import com.adobe.marketing.mobile.AdobeCallback;

public class MainApp extends Application {

  private final String ENVIRONMENT_FILE_ID = "YOUR_APP_ENVIRONMENT_ID";

    @Override
    public void onCreate() {
        super.onCreate();

        MobileCore.setApplication(this);
        MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID);

        MobileCore.registerExtensions(
            Arrays.asList(Edge.EXTENSION, Identity.EXTENSION, Optimize.EXTENSION),
            o -> Log.d("MainApp", "Offer Decisioning and Target Mobile SDK was initialized.")
        );
    }
}
目標SDK

移轉前的Java初始化程式碼

code language-java
import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Analytics;
import com.adobe.marketing.mobile.Extension;
import com.adobe.marketing.mobile.Identity;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Signal;
import com.adobe.marketing.mobile.Target;
import com.adobe.marketing.mobile.UserProfile;
import java.util.Arrays;
import java.util.List;
...
import android.app.Application;
...
public class MainApp extends Application {
...
    @Override
    public void onCreate() {
        super.onCreate();
        MobileCore.setApplication(this);
        MobileCore.setLogLevel(LoggingMode.DEBUG);
        ...
        List<Class<? extends Extension>> extensions = Arrays.asList(
            Analytics.EXTENSION,
            Target.EXTENSION,
            Identity.EXTENSION,
            Lifecycle.EXTENSION,
            Signal.EXTENSION,
            UserProfile.EXTENSION
        );


        MobileCore.registerExtensions(extensions, new AdobeCallback () {
            @Override
            public void call(Object o) {
                MobileCore.configureWithAppID(<Environment File ID>);
            }
        });
    }
}
iOS
tabs
最佳化SDK

移轉後的Swift初始化程式碼

code language-swift
import AEPCore
import AEPEdge
import AEPEdgeIdentity
import AEPOptimize

@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {

      // register the extensions
      MobileCore.registerExtensions([Edge.self, AEPEdgeIdentity.Identity.self, Optimize.self]) {
        MobileCore.configureWith(appId: <YOUR_ENVIRONMENT_FILE_ID>) // Replace <YOUR_ENVIRONMENT_FILE_ID> with a String containing your own ID.
      }

      return true
  }
}
目標SDK

移轉前的Swift初始化程式碼

code language-swift
import AEPCore
import AEPAnalytics
import AEPTarget
import AEPIdentity
import AEPLifecycle
import AEPSignal
import AEPServices
import AEPUserProfile
...
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        MobileCore.setLogLevel(.debug)
        let appState = application.applicationState
        ...
        let extensions = [
            Analytics.self,
            Target.self,
            Identity.self,
            Lifecycle.self,
            Signal.self,
            UserProfile.self
        ]
        MobileCore.registerExtensions(extensions, {
        MobileCore.configureWith(<Environment File ID>)
        if appState != .background {
            MobileCore.lifecycleStart(additionalContextData: ["contextDataKey": "contextDataVal"])
            }
        })
        ...
        return true
    }
}

API比較

許多Target擴充功能API都有等同的方法使用Offer Decisioning和Target擴充功能,如下表所述。 如需函式的詳細資訊,請參閱API參考。

目標延伸功能
Offer Decisioning和Target擴充功能
附註
prefetchContent
updatePropositions
retrieveLocationContent
getPropositions
使用getPropositions API時,不會進行遠端呼叫以擷取SDK中未快取的領域。
displayedLocations
選件 — >已顯示()
此外,generateDisplayInteractionXdm選件方法可用來產生專案顯示的XDM。 隨後,Edge網路SDK的sendEvent API可用於附加其他XDM自由格式資料,並將體驗事件傳送至遠端。
clickedLocation
選件 — >已點選()
此外,generateTapInteractionXdm選件方法可用來產生專案點選的XDM。 隨後,Edge網路SDK的sendEvent API可用於附加其他XDM自由格式資料,並將體驗事件傳送至遠端。
clearPrefetchCache
clearCachedPropositions
resetExperience
不適用
使用SDK的Edge Network延伸模組識別碼中的removeIdentity API來停止將訪客識別碼傳送至Edge網路。 如需詳細資訊,請參閱removeIdentity API檔案

注意:行動核心的resetIdentities API清除了SDK中所有儲存的身分識別,包括Experience Cloud ID (ECID),應謹慎使用!
getSessionId
不適用
state:store回應控制代碼包含工作階段相關資訊。 Edge網路擴充功能可將未過期的狀態存放區專案附加至後續請求,協助您管理該專案。
setSessionId
不適用
state:store回應控制代碼包含工作階段相關資訊。 Edge網路擴充功能可將未過期的狀態存放區專案附加至後續請求,協助您管理該專案。
getThirdPartyId
不適用
使用適用於Edge Network擴充功能之身分的updateIdentities API來提供第三方ID值。 然後,在資料流中設定第三方ID名稱空間。 如需更多詳細資料,請參閱Target第三方ID行動檔案
setThirdPartyId
不適用
使用適用於Edge Network擴充功能之身分的updateIdentities API來提供第三方ID值。 然後,在資料流中設定第三方ID名稱空間。 如需更多詳細資料,請參閱Target第三方ID行動檔案
getTntId
不適用
locationHint:result回應控制代碼包含Target位置提示資訊。 我們假設Target邊緣會與Experience Edge位於同一位置。

Edge網路擴充功能會使用EdgeNetwork位置提示來決定要傳送請求的Edge網路叢集。 若要跨SDK (混合式應用程式)共用Edge網路位置提示,請使用Edge Network擴充功能中的getLocationHintsetLocationHint API。 如需詳細資訊,請參閱getLocationHint API檔案
setTntId
不適用
locationHint:result回應控制代碼包含Target位置提示資訊。 我們假設Target邊緣會與Experience Edge位於同一位置。

Edge網路擴充功能會使用EdgeNetwork位置提示來決定要傳送請求的Edge網路叢集。 若要跨SDK (混合式應用程式)共用Edge網路位置提示,請使用Edge Network擴充功能中的getLocationHintsetLocationHint API。 如需詳細資訊,請參閱getLocationHint API檔案

接下來,瞭解如何請求並將活動轉譯到頁面。

NOTE
我們致力協助您成功將行動Target從Target擴充功能移轉至Offer Decisioning和Target擴充功能。 如果您在移轉時遇到問題,或覺得本指南中缺少重要資訊,請在此社群討論中張貼以告知我們。
recommendation-more-help
23093022-70e6-46bf-81c6-76f79c282c9c