步驟 3-在您的行動應用程式中註冊擴充功能
Last update: Fri Jul 19 2024 00:00:00 GMT+0000 (Coordinated Universal Time)
- 主題:
- 推送
建立對象:
- 經驗豐富
在本部分中,我們會新增程式碼以註冊使用者設定檔、身分、生命週期和訊號擴充功能。 我們也必須註冊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屬性的環境檔案識別碼。 您可從Launch屬性的environment tab存取此專案。
recommendation-more-help
1e5f790f-a0c6-45cc-9e9a-a41393306233