Engagelab通道集成文檔

最新更新:2022-11-29

獲取應用信息

在控制台上創建應用,創建成功後自動生成 AppKey 用以標識該應用,詳情參考 應用設置文檔

1.libs導包

  • 手動方式
    將libs包下面的mt-sdk-x.x.x.aar導入libs目錄
              將libs包下面的mt-sdk-x.x.x.aar導入libs目錄
    
            
    此代碼塊在浮窗中顯示
  • 自動方式
    dependencies { //必須 主包 implementation 'com.engagelab:engagelab:4.3.3' // 此處以4.3.3 版本為例。 //可選,google廠商 implementation 'com.engagelab.plugin:google:4.3.3' // 此處以4.3.3 版本為例。 //可選,honor廠商 implementation 'com.engagelab.plugin:honor:4.3.3' // 此處以4.3.3 版本為例。 implementation 'com.engagelab.plugin:honor_th_push:4.3.3' // 此處以4.3.3 版本為例。 //可選,huawei廠商 implementation 'com.engagelab.plugin:huawei:4.3.3' // 此處以4.3.3 版本為例。 //可選,mi廠商,國內版 implementation 'com.engagelab.plugin:mi:4.3.3' // 此處以4.3.3 版本為例。 //可選,mi廠商,海外版 implementation 'com.engagelab.plugin:mi_global:4.3.3' // 此處以4.3.3 版本為例。 //可選,meizu廠商 implementation 'com.engagelab.plugin:meizu:4.3.3' // 此處以4.3.3 版本為例。 //可選,oppo廠商 implementation 'com.engagelab.plugin:oppo:4.3.3' // 此處以4.3.3 版本為例。 implementation 'com.engagelab.plugin:oppo_th_push:4.3.3' // 此處以4.3.3 版本為例。 //可選,vivo廠商 implementation 'com.engagelab.plugin:vivo:4.3.3' // 此處以4.3.3 版本為例。 }
              dependencies {
      //必須 主包
      implementation 'com.engagelab:engagelab:4.3.3' // 此處以4.3.3 版本為例。
      //可選,google廠商
      implementation 'com.engagelab.plugin:google:4.3.3' // 此處以4.3.3 版本為例。
      //可選,honor廠商
      implementation 'com.engagelab.plugin:honor:4.3.3' // 此處以4.3.3 版本為例。
      implementation 'com.engagelab.plugin:honor_th_push:4.3.3' // 此處以4.3.3 版本為例。
      //可選,huawei廠商
      implementation 'com.engagelab.plugin:huawei:4.3.3' // 此處以4.3.3 版本為例。
      //可選,mi廠商,國內版
      implementation 'com.engagelab.plugin:mi:4.3.3' // 此處以4.3.3 版本為例。
      //可選,mi廠商,海外版
      implementation 'com.engagelab.plugin:mi_global:4.3.3' // 此處以4.3.3 版本為例。
      //可選,meizu廠商
      implementation 'com.engagelab.plugin:meizu:4.3.3' // 此處以4.3.3 版本為例。
      //可選,oppo廠商
      implementation 'com.engagelab.plugin:oppo:4.3.3' // 此處以4.3.3 版本為例。
      implementation 'com.engagelab.plugin:oppo_th_push:4.3.3' // 此處以4.3.3 版本為例。
      //可選,vivo廠商
      implementation 'com.engagelab.plugin:vivo:4.3.3' // 此處以4.3.3 版本為例。
    }
    
            
    此代碼塊在浮窗中顯示

2.build.gradle配置

plugins { id 'com.android.application' } android { ... defaultConfig { // app packageName,需要與控制台上的一樣 applicationId "com.engagelab.app" ... manifestPlaceholders = [ //appKey,需要與控制台上的一樣,與packageName是一對一關係 ENGAGELAB_PRIVATES_APPKEY : "您的appkey", // Engagelab appChannel,用於渠道統計 ENGAGELAB_PRIVATES_CHANNEL: "developer", // Engagelab process,Engagelabsdk工作所在的進程,注意:開頭 ENGAGELAB_PRIVATES_PROCESS: ":remote", //數據中心名稱,填空""時,默认"Singapore"數據中心 ENGAGELAB_PRIVATES_SITE_NAME: "Singapore" ] } } dependencies { implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') }
          plugins {
    id 'com.android.application'
}

android {
    ...

    defaultConfig {
        // app packageName,需要與控制台上的一樣
        applicationId "com.engagelab.app"
        ...
                
        manifestPlaceholders = [
                //appKey,需要與控制台上的一樣,與packageName是一對一關係
                ENGAGELAB_PRIVATES_APPKEY : "您的appkey",
                // Engagelab appChannel,用於渠道統計
                ENGAGELAB_PRIVATES_CHANNEL: "developer",
                // Engagelab process,Engagelabsdk工作所在的進程,注意:開頭
                ENGAGELAB_PRIVATES_PROCESS: ":remote",
                //數據中心名稱,填空""時,默认"Singapore"數據中心
                ENGAGELAB_PRIVATES_SITE_NAME: "Singapore"
        ]
    }
}

dependencies {
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
}

        
此代碼塊在浮窗中顯示

3.創建必須組件

package com.engagelab.app.component; import com.engagelab.privates.common.component.MTCommonService; /** * 開發者繼承MTCommonService,可以使長連接更長時間存活 * <p> * 空實現即可 */ public class UserService extends MTCommonService { } package com.engagelab.app.component; import android.content.Context; import android.widget.Toast; import java.util.Arrays; import com.engagelab.app.common.ExampleGlobal; import com.engagelab.app.listener.StatusObserver; import com.engagelab.app.log.ExampleLogger; import com.engagelab.privates.common.component.MTCommonReceiver; import com.engagelab.privates.core.api.MTCorePrivatesApi; import com.engagelab.privates.core.api.WakeMessage; import com.engagelab.privates.push.api.CustomMessage; import com.engagelab.privates.push.api.MobileNumberMessage; import com.engagelab.privates.push.api.NotificationMessage; import com.engagelab.privates.push.api.PlatformTokenMessage; /** * 開發者繼承MTCommonReceiver,可以獲得sdk的方法回調 * <p> * 所有回調均在主線程 */ public class UserReceiver extends MTCommonReceiver { private static final String TAG = "UserReceiver"; /** * 應用通知開關狀態回調 * * @param context 不為空 * @param enable 通知開關是否開,true為打開,false為關閉 */ @Override public void onNotificationStatus(Context context, boolean enable) { ExampleLogger.i(TAG, "onNotificationStatus:" + enable); Toast.makeText(context.getApplicationContext(), "onNotificationStatus " + enable, Toast.LENGTH_SHORT).show(); ExampleGlobal.isNotificationEnable = enable; if (StatusObserver.getInstance().getListener() != null) { StatusObserver.getInstance().getListener().onNotificationStatus(enable); } } /** * 長連接狀態回調 * * @param context 不為空 * @param enable 是否連接 */ @Override public void onConnectStatus(Context context, boolean enable) { ExampleLogger.i(TAG, "onConnectState:" + enable); Toast.makeText(context.getApplicationContext(), "onConnectStatus " + enable, Toast.LENGTH_SHORT).show(); ExampleGlobal.isConnectEnable = enable; if (StatusObserver.getInstance().getListener() != null) { StatusObserver.getInstance().getListener().onConnectStatus(enable); } // 長連接成功可獲取registrationId if (enable) { String registrationId = MTCorePrivatesApi.getRegistrationId(context); ExampleLogger.i(TAG, "registrationId:" + registrationId); } } /** * 通知消息到達回調 * * @param context 不為空 * @param notificationMessage 通知消息 */ @Override public void onNotificationArrived(Context context, NotificationMessage notificationMessage) { ExampleLogger.i(TAG, "onNotificationArrived:" + notificationMessage.toString()); } /** * 通知消息在前台不顯示 * * @param context 不為空 * @param notificationMessage 通知消息 */ @Override public void onNotificationUnShow(Context context, NotificationMessage notificationMessage) { ExampleLogger.i(TAG, "onNotificationUnShow:" + notificationMessage.toString()); } /** * 通知消息點擊回調 * * @param context 不為空 * @param notificationMessage 通知消息 */ @Override public void onNotificationClicked(Context context, NotificationMessage notificationMessage) { ExampleLogger.i(TAG, "onNotificationClicked:" + notificationMessage.toString()); } /** * 通知消息刪除回調 * * @param context 不為空 * @param notificationMessage 通知消息 */ @Override public void onNotificationDeleted(Context context, NotificationMessage notificationMessage) { ExampleLogger.i(TAG, "onNotificationDeleted:" + notificationMessage.toString()); } /** * 自定義消息回調 * * @param context 不為空 * @param customMessage 自定義消息 */ @Override public void onCustomMessage(Context context, CustomMessage customMessage) { ExampleLogger.i(TAG, "onCustomMessage:" + customMessage.toString()); } /** * 廠商token消息回調 * * @param context 不為空 * @param platformTokenMessage 廠商token消息 */ @Override public void onPlatformToken(Context context, PlatformTokenMessage platformTokenMessage) { ExampleLogger.i(TAG, "onPlatformToken:" + platformTokenMessage.toString()); } }
          package com.engagelab.app.component;

import com.engagelab.privates.common.component.MTCommonService;

/**
 * 開發者繼承MTCommonService,可以使長連接更長時間存活
 * <p>
 * 空實現即可
 */
public class UserService extends MTCommonService {


}
package com.engagelab.app.component;

import android.content.Context;
import android.widget.Toast;

import java.util.Arrays;

import com.engagelab.app.common.ExampleGlobal;
import com.engagelab.app.listener.StatusObserver;
import com.engagelab.app.log.ExampleLogger;
import com.engagelab.privates.common.component.MTCommonReceiver;
import com.engagelab.privates.core.api.MTCorePrivatesApi;
import com.engagelab.privates.core.api.WakeMessage;
import com.engagelab.privates.push.api.CustomMessage;
import com.engagelab.privates.push.api.MobileNumberMessage;
import com.engagelab.privates.push.api.NotificationMessage;
import com.engagelab.privates.push.api.PlatformTokenMessage;

/**
 * 開發者繼承MTCommonReceiver,可以獲得sdk的方法回調
 * <p>
 * 所有回調均在主線程
 */
public class UserReceiver extends MTCommonReceiver {

    private static final String TAG = "UserReceiver";

    /**
     * 應用通知開關狀態回調
     *
     * @param context 不為空
     * @param enable  通知開關是否開,true為打開,false為關閉
     */
    @Override
    public void onNotificationStatus(Context context, boolean enable) {
        ExampleLogger.i(TAG, "onNotificationStatus:" + enable);
        Toast.makeText(context.getApplicationContext(), "onNotificationStatus " + enable, Toast.LENGTH_SHORT).show();
        ExampleGlobal.isNotificationEnable = enable;
        if (StatusObserver.getInstance().getListener() != null) {
            StatusObserver.getInstance().getListener().onNotificationStatus(enable);
        }
    }

    /**
     * 長連接狀態回調
     *
     * @param context 不為空
     * @param enable  是否連接
     */
    @Override
    public void onConnectStatus(Context context, boolean enable) {
        ExampleLogger.i(TAG, "onConnectState:" + enable);
        Toast.makeText(context.getApplicationContext(), "onConnectStatus " + enable, Toast.LENGTH_SHORT).show();
        ExampleGlobal.isConnectEnable = enable;
        if (StatusObserver.getInstance().getListener() != null) {
            StatusObserver.getInstance().getListener().onConnectStatus(enable);
        }
        // 長連接成功可獲取registrationId
        if (enable) {
            String registrationId = MTCorePrivatesApi.getRegistrationId(context);
            ExampleLogger.i(TAG, "registrationId:" + registrationId);
        }
    }

    /**
     * 通知消息到達回調
     *
     * @param context             不為空
     * @param notificationMessage 通知消息
     */
    @Override
    public void onNotificationArrived(Context context, NotificationMessage notificationMessage) {
        ExampleLogger.i(TAG, "onNotificationArrived:" + notificationMessage.toString());
    }

    /**
     * 通知消息在前台不顯示
     *
     * @param context             不為空
     * @param notificationMessage 通知消息
     */
    @Override
    public void onNotificationUnShow(Context context, NotificationMessage notificationMessage) {
        ExampleLogger.i(TAG, "onNotificationUnShow:" + notificationMessage.toString());
    }

    /**
     * 通知消息點擊回調
     *
     * @param context             不為空
     * @param notificationMessage 通知消息
     */
    @Override
    public void onNotificationClicked(Context context, NotificationMessage notificationMessage) {
        ExampleLogger.i(TAG, "onNotificationClicked:" + notificationMessage.toString());
    }

    /**
     * 通知消息刪除回調
     *
     * @param context             不為空
     * @param notificationMessage 通知消息
     */
    @Override
    public void onNotificationDeleted(Context context, NotificationMessage notificationMessage) {
        ExampleLogger.i(TAG, "onNotificationDeleted:" + notificationMessage.toString());
    }

    /**
     * 自定義消息回調
     *
     * @param context       不為空
     * @param customMessage 自定義消息
     */
    @Override
    public void onCustomMessage(Context context, CustomMessage customMessage) {
        ExampleLogger.i(TAG, "onCustomMessage:" + customMessage.toString());
    }

    /**
     * 廠商token消息回調
     *
     * @param context              不為空
     * @param platformTokenMessage 廠商token消息
     */
    @Override
    public void onPlatformToken(Context context, PlatformTokenMessage platformTokenMessage) {
        ExampleLogger.i(TAG, "onPlatformToken:" + platformTokenMessage.toString());
    }

}

        
此代碼塊在浮窗中顯示

4.AndroidManifest.xml配置

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.engagelab.app"> <!-- 必須,網絡權限 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 可選,通知震動 --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:name="com.engagelab.app.MainApplication" android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.MT" android:usesCleartextTraffic="true" tools:targetApi="m"> <!-- 如果使用http請求,則需要允許使用http --> <!-- 由於此類具有長連接功能,手機廠商省電優化時可能直接殺死包名帶Engagelab字樣的service --> <!-- 所以需要開發者繼承com.engagelab.app.component.MTCommonService,提升長連接存活率,已達到提高消息到達率的目的 --> <service android:name="com.engagelab.app.component.UserService" android:exported="false" android:process="${ENGAGELAB_PRIVATES_PROCESS}"> <intent-filter> <action android:name="com.engagelab.privates.intent.USER_SERVICE" /> </intent-filter> </service> <!-- 用於接收Engagelab業務的回調,包含了長連接狀態/通知開關狀態/通知消息到達/通知消息點擊/通知消息刪除/自定義消息/廠商token回調 --> <!-- 不需要配置子進程,此回調中在主進程中,方便業務操作 --> <receiver android:name="com.engagelab.app.component.UserReceiver" android:exported="false"> <intent-filter> <action android:name="com.engagelab.privates.intent.USER_RECEIVER" /> </intent-filter> </receiver> </application> </manifest>
          <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.engagelab.app">
        
    <!-- 必須,網絡權限 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- 可選,通知震動 -->
    <uses-permission android:name="android.permission.VIBRATE" /> 
        
    <application
        android:name="com.engagelab.app.MainApplication"
        android:allowBackup="false"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.MT"
        android:usesCleartextTraffic="true"
        tools:targetApi="m"> <!-- 如果使用http請求,則需要允許使用http -->

        <!-- 由於此類具有長連接功能,手機廠商省電優化時可能直接殺死包名帶Engagelab字樣的service -->
        <!-- 所以需要開發者繼承com.engagelab.app.component.MTCommonService,提升長連接存活率,已達到提高消息到達率的目的 -->
        <service
            android:name="com.engagelab.app.component.UserService"
            android:exported="false"
            android:process="${ENGAGELAB_PRIVATES_PROCESS}">
            <intent-filter>
                <action android:name="com.engagelab.privates.intent.USER_SERVICE" />
            </intent-filter>
        </service>

        <!-- 用於接收Engagelab業務的回調,包含了長連接狀態/通知開關狀態/通知消息到達/通知消息點擊/通知消息刪除/自定義消息/廠商token回調 -->
        <!-- 不需要配置子進程,此回調中在主進程中,方便業務操作 -->
        <receiver
            android:name="com.engagelab.app.component.UserReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.engagelab.privates.intent.USER_RECEIVER" />
            </intent-filter>
        </receiver>

    </application>

</manifest>

        
此代碼塊在浮窗中顯示

5.環境配置

package com.engagelab.app; import android.app.Application; import com.engagelab.privates.core.api.Address; import com.engagelab.privates.core.api.MTCorePrivatesApi; import com.engagelab.privates.push.api.MTPushPrivatesApi; /** * 用於演示ENGAGELAB-sdk配置 */ public class MainApplication extends Application { private static final String TAG = "MainApplication"; @Override public void onCreate() { super.onCreate(); // 必須在application.onCreate中配置,不要判斷進程,sdk內部有判斷 MTCorePrivatesApi.configDebugMode(this, true); // 後台沒升級tag: V3.5.4-newportal-20210823-gamma.57版本,前端必須調用此方法,否則通知點擊跳轉有問題 // MTPushPrivatesApi.configOldPushVersion(context.getApplicationContext()); // 初始化推送 // MTPushPrivatesApi.init(this); } }
          package com.engagelab.app;

import android.app.Application;

import com.engagelab.privates.core.api.Address;
import com.engagelab.privates.core.api.MTCorePrivatesApi;
import com.engagelab.privates.push.api.MTPushPrivatesApi;

/**
 * 用於演示ENGAGELAB-sdk配置
 */
public class MainApplication extends Application {

    private static final String TAG = "MainApplication";

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


        // 必須在application.onCreate中配置,不要判斷進程,sdk內部有判斷
        MTCorePrivatesApi.configDebugMode(this, true);

        // 後台沒升級tag: V3.5.4-newportal-20210823-gamma.57版本,前端必須調用此方法,否則通知點擊跳轉有問題
        // MTPushPrivatesApi.configOldPushVersion(context.getApplicationContext());

        // 初始化推送
        // MTPushPrivatesApi.init(this);
    }

}

        
此代碼塊在浮窗中顯示

6.創建通知點擊跳轉組件

package com.engagelab.app.component; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; import com.engagelab.app.R; import com.engagelab.app.log.ExampleLogger; import com.engagelab.privates.push.api.MTPushPrivatesApi; import com.engagelab.privates.push.api.NotificationMessage; import com.engagelab.privates.push.constants.MTPushConstants; /** * 用於演示-點擊通知後activity跳轉 * * 確保沒有調用{@link MTPushPrivatesApi#configOldPushVersion(Context)},否則通知點擊跳轉不會跳轉到此頁面 * <p> * 不需要調用{@link MTPushPrivatesApi#reportNotificationOpened(Context, String, byte, String)},sdk內部已做處理 */ public class UserActivity400 extends Activity { private static final String TAG = "UserActivity400"; private TextView tvMessage; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intent); tvMessage = findViewById(R.id.tv_message); onIntent(getIntent()); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); onIntent(intent); } private void onIntent(Intent intent) { try { Toast.makeText(this, TAG, Toast.LENGTH_SHORT).show(); if (intent == null) { return; } //3.4.0版本開始不再使用對象,而使用json數據 String notificationMessage = intent.getStringExtra("message_json"); if (notificationMessage == null) { return; } ExampleLogger.d(TAG, "notificationMessage:" + notificationMessage.toString()); tvMessage.setText(notificationMessage.toString()); } catch (Throwable throwable) { throwable.printStackTrace(); } } }
          package com.engagelab.app.component;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.engagelab.app.R;
import com.engagelab.app.log.ExampleLogger;
import com.engagelab.privates.push.api.MTPushPrivatesApi;
import com.engagelab.privates.push.api.NotificationMessage;
import com.engagelab.privates.push.constants.MTPushConstants;

/**
 * 用於演示-點擊通知後activity跳轉
 *
 * 確保沒有調用{@link MTPushPrivatesApi#configOldPushVersion(Context)},否則通知點擊跳轉不會跳轉到此頁面
 * <p>
 * 不需要調用{@link MTPushPrivatesApi#reportNotificationOpened(Context, String, byte, String)},sdk內部已做處理
 */
public class UserActivity400 extends Activity {

    private static final String TAG = "UserActivity400";

    private TextView tvMessage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intent);
        tvMessage = findViewById(R.id.tv_message);
        onIntent(getIntent());
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        onIntent(intent);
    }

    private void onIntent(Intent intent) {
        try {
            Toast.makeText(this, TAG, Toast.LENGTH_SHORT).show();
            if (intent == null) {
                return;
            }
            //3.4.0版本開始不再使用對象,而使用json數據
            String notificationMessage = intent.getStringExtra("message_json");
            if (notificationMessage == null) {
                return;
            }
            ExampleLogger.d(TAG, "notificationMessage:" + notificationMessage.toString());
            tvMessage.setText(notificationMessage.toString());
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }
        
}

        
此代碼塊在浮窗中顯示

7.AndroidManifest.xml點擊跳轉組件配置

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.engagelab.app"> <!-- 必須,網絡權限 --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 可選,通知震動 --> <uses-permission android:name="android.permission.VIBRATE" /> <application android:name="com.engagelab.app.MainApplication" android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.MT" android:usesCleartextTraffic="true" tools:targetApi="m"> <!-- 如果使用http請求,則需要允許使用http --> .............................................................. <!-- 用於演示通知點擊跳轉 --> <activity android:name="com.engagelab.app.component.UserActivity400" android:exported="false" android:launchMode="singleTask" /> <!-- 用於演示deepLink的通知點擊跳轉 --> <!-- <activity--> <!-- android:name="com.engagelab.app.component.UserActivity400"--> <!-- android:exported="false" >--> <!-- <intent-filter>--> <!-- <data android:scheme="你的scheme"/>--> <!-- <data android:host="你的host"/>--> <!-- <action android:name="android.intent.action.VIEW" />--> <!-- <category android:name="android.intent.category.DEFAULT" />--> <!-- <category android:name="android.intent.category.BROWSABLE" />--> <!-- </intent-filter>--> <!-- </activity>--> <!--白名單本地中轉驗證:MTPush4.2.3版本開始,配置ENGAGELAB_PRIVATES_TRANSFER後,sdk會做本地驗證;不配置就不做本地驗證。如果開啟本地驗證,請將要跳轉的目標Activity配置在這裡;如果有多個目標Activity,請用/分割開。--> <meta-data android:name="ENGAGELAB_PRIVATES_TRANSFER" android:value="com.engagelab.app.component.UserActivity400" /> <!-- google push need,不需要 google 通道,则删除 --> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/mtpush_notification_icon" /> <!-- huawei push need,不需要 huawei 通道,则删除 --> <meta-data android:name="com.huawei.messaging.default_notification_icon" android:resource="@drawable/mtpush_notification_icon" /> </application> </manifest>
          <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.engagelab.app">

    <!-- 必須,網絡權限 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- 可選,通知震動 -->
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:name="com.engagelab.app.MainApplication"
        android:allowBackup="false"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.MT"
        android:usesCleartextTraffic="true"
        tools:targetApi="m"> <!-- 如果使用http請求,則需要允許使用http -->

        ..............................................................

        <!-- 用於演示通知點擊跳轉 -->
        <activity
            android:name="com.engagelab.app.component.UserActivity400"
            android:exported="false"
            android:launchMode="singleTask" />

        <!-- 用於演示deepLink的通知點擊跳轉 -->
<!--        <activity-->
<!--            android:name="com.engagelab.app.component.UserActivity400"-->
<!--            android:exported="false" >-->
<!--            <intent-filter>-->
<!--                <data android:scheme="你的scheme"/>-->
<!--                <data android:host="你的host"/>-->
<!--                <action android:name="android.intent.action.VIEW" />-->
<!--                <category android:name="android.intent.category.DEFAULT" />-->
<!--                <category android:name="android.intent.category.BROWSABLE" />-->
<!--            </intent-filter>-->
<!--        </activity>-->

            
        <!--白名單本地中轉驗證:MTPush4.2.3版本開始,配置ENGAGELAB_PRIVATES_TRANSFER後,sdk會做本地驗證;不配置就不做本地驗證。如果開啟本地驗證,請將要跳轉的目標Activity配置在這裡;如果有多個目標Activity,請用/分割開。-->
        <meta-data
            android:name="ENGAGELAB_PRIVATES_TRANSFER"
            android:value="com.engagelab.app.component.UserActivity400" />
                
        <!-- google push need,不需要 google 通道,则删除 -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/mtpush_notification_icon" />

        <!-- huawei push need,不需要 huawei 通道,则删除 -->
        <meta-data
            android:name="com.huawei.messaging.default_notification_icon"
            android:resource="@drawable/mtpush_notification_icon" />

    </application>

</manifest>

        
此代碼塊在浮窗中顯示
在文档中心打开