步驟 3-在您的行動應用程式中註冊擴充功能

在本部分中,我們會新增程式碼以註冊使用者設定檔、身分、生命週期和訊號擴充功能。 我們也必須註冊Adobe Campaign Standard擴充功能,如下列程式碼所示。

在中開啟您的專案 Android 工作室。 刪除MainApp中的整個程式碼 第一行是您的封裝陳述式除外.

將下列程式碼貼入MainApp

import android.app.Application;
import android.util.Log;

import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Campaign;
import com.adobe.marketing.mobile.Identity;
import com.adobe.marketing.mobile.InvalidInitException;
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.UserProfile;

public class MainApp extends Application {

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

MobileCore.setApplication(this);
MobileCore.setLogLevel(LoggingMode.DEBUG);

try{
    Campaign.registerExtension();
    UserProfile.registerExtension();
    Identity.registerExtension();
    Lifecycle.registerExtension();
    Signal.registerExtension();
    MobileCore.start(new AdobeCallback () {
        @Override
        public void call(Object o) {
            MobileCore.configureWithAppID("copy your launch property id here");
        }
    });
} catch (InvalidInitException e) {
    Log.d("ACS Exception", "exception");
}
}
}

第32行,您必須提供​ Launch 屬性的環境檔案識別碼。 您可從「 」存取 environment tab 的 Launch 屬性。

launch-id

recommendation-more-help
1e5f790f-a0c6-45cc-9e9a-a41393306233