Auxiliary pop-up window integration (4.x)

Updated at:

This topic describes how to configure a transit activity for notification opened events from vendor channels in Android SDK 4.x and how to process these events using a unified callback.

Applicability

The examples in this topic are based on Android SDK 4.0.0 and apply to notifications from vendor channels that use an auxiliary pop-up window, such as Xiaomi, Huawei, Honor, OPPO, vivo, and Meizu. FCM data messages are handled directly by the Mobile Push SDK and do not require this transit activity. If you are using SDK 3.x, see Auxiliary pop-up window integration (3.x). If you are upgrading from 3.x, migrate your legacy callback logic first.

Important

SDK 4.x still requires an auxiliary pop-up window activity. The key change is the location of the callback for notification opened events. After the data is successfully parsed, either MessageReceiver or AliyunMessageIntentService receives the event in the onNotificationOpened method.

Do not implement onSysNoticeOpened, onNotPushData, onParseFailed, or PopupNotifyClickListener to handle notification opened events.

Android SDK 4.x upgrade guide

Prerequisites

  • You have integrated the Android SDK 4.x core package and completed the required configuration on vendor platforms and in the EMAS console.

  • You are using matching versions for the core SDK, the base adapter package for vendor channels, and the specific vendor adapter package. For SDK 4.0.0 integration, use the corresponding 4.0.0 adapter packages.

  • You have configured a MessageReceiver or an IntentService at application startup to ensure necessary initialization occurs, even when a notification from a vendor channel triggers a cold start.

Android SDK integration (4.x)

Step 1: Configure a transit activity

Choose one of the following two methods. The fully qualified class name of the activity must be consistent with the name specified in the AndroidManifest.xml file and the server-side push parameters.

Method 1: Extend AndroidPopupActivity

package com.example.push;

import com.alibaba.sdk.android.push.AndroidPopupActivity;

public class MyPopupActivity extends AndroidPopupActivity {
    // In SDK 4.x, this acts as the transit entry for vendor channel notification opened events. You do not need to implement onSysNoticeOpened.
}

Method 2: Use PopupNotifyClick in an existing activity

If your business activity already extends your app's BaseActivity, you can maintain its inheritance and add the following lifecycle calls. The example uses a standard Activity to demonstrate the required methods.

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.alibaba.sdk.android.push.popup.PopupNotifyClick;

public class MyPopupActivity extends Activity {
    private final PopupNotifyClick popupNotifyClick = new PopupNotifyClick();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        popupNotifyClick.onCreate(this, getIntent());
    }

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

For either method, register the activity under the application node in your AndroidManifest.xml file:

<activity
    android:name="com.example.push.MyPopupActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="${applicationId}"
            android:path="/thirdpush"
            android:scheme="agoo" />
    </intent-filter>
</activity>

Replace the example class name with your activity's fully qualified name. Retain your existing activity's layout, routing, and lifecycle logic.

Step 2: Configure the unified callback

Important

In Android SDK 4.x, the business callback scopes for MessageReceiver and AliyunMessageIntentService are as follows:

  • ACCS proprietary channel and FCM: Support all business callbacks, including message reception (onMessage), notification arrival (onNotification), notification opened (onNotificationOpened), and notification removed (onNotificationRemoved).

  • Other Android vendor channels (excluding FCM): Only support onNotificationOpened (notification opened). Other callbacks, such as message reception, notification arrival, and notification removed, are not triggered.

Choose one of the following two receiving methods. The fourth parameter of onNotificationOpened is a Map<String, String>, so you no longer need to parse it as a JSON string.

Method 1: Use MessageReceiver

package com.example.push;

import android.content.Context;
import com.alibaba.sdk.android.push.MessageReceiver;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import java.util.Map;

public class MyMessageReceiver extends MessageReceiver {
    @Override
    public void onMessage(Context context, CPushMessage message) {
        // Handle pass-through messages as needed by your application.
    }

    @Override
    public void onNotification(Context context, String title,
            String summary, Map<String, String> extraMap) {
        // Handle notification arrival as needed by your application.
    }

    @Override
    public void onNotificationRemoved(Context context, String messageId) {
        // Handle notification removed events as needed by your application.
    }

    @Override
    public void onNotificationOpened(Context context, String title,
            String summary, Map<String, String> extraMap) {
        String orderId = extraMap == null ? null : extraMap.get("orderId");
        // Notification opened events from both proprietary and vendor channels are handled here.
        // Based on business parameters such as orderId, forward the event to your application's page routing logic.
    }
}
<receiver
    android:name="com.example.push.MyMessageReceiver"
    android:exported="false">
    <intent-filter>
        <action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
        <action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
        <action android:name="com.alibaba.sdk.android.push.RECEIVE" />
    </intent-filter>
</receiver>

Method 2: Use AliyunMessageIntentService

package com.example.push;

import android.content.Context;
import com.alibaba.sdk.android.push.AliyunMessageIntentService;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import java.util.Map;

public class MyMessageIntentService extends AliyunMessageIntentService {
    @Override
    public void onMessage(Context context, CPushMessage message) {
        // Handle pass-through messages as needed by your application.
    }

    @Override
    public void onNotification(Context context, String title,
            String summary, Map<String, String> extraMap) {
        // Handle notification arrival as needed by your application.
    }

    @Override
    public void onNotificationRemoved(Context context, String messageId) {
        // Handle notification removed events as needed by your application.
    }

    @Override
    public void onNotificationOpened(Context context, String title,
            String summary, Map<String, String> extraMap) {
        String orderId = extraMap == null ? null : extraMap.get("orderId");
        // Handle notification opened events here.
    }
}
<service
    android:name="com.example.push.MyMessageIntentService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
        <action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
        <action android:name="com.alibaba.sdk.android.push.RECEIVE" />
    </intent-filter>
</service>

Set the service class after PushServiceFactory.init() is called and before registration begins:

CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.setPushIntentService(MyMessageIntentService.class);
Important

After you call setPushIntentService, this IntentService handles callbacks instead of MessageReceiver. If you do not call setPushIntentService, MessageReceiver is used by default.

After the transit activity parses a notification opened event from a vendor channel, the SDK delivers the event to your application through the onNotificationOpened callback. Centralize your page routing logic in this callback.

Step 3: Configure server-side push parameters

API

Vendor entry point

Title and body

Push / MassPush

AndroidPopupActivity: Enter the fully qualified class name of the transit activity.

Use AndroidPopupTitle and AndroidPopupBody to set the content for vendor channel notifications. You must also specify the Title and Body parameters.

PushV2 / MassPushV2

PushTask.Notification.Android.VendorChannelActivity: Enter the fully qualified class name of the same transit activity.

Use PushTask.Notification.Title and Body.

When using the Push API operation, you must also configure basic parameters such as StoreOffline and the target device as required by the API. When sending pushes from the console, specify the click-through activity and notification content in the vendor channel settings.

After migrating the client-side callbacks, you must still configure the server-side parameters for vendor channel notifications as described in this section.

Verify integration

  • After PushServiceFactory.init() and before calling register and other vendor-specific registration methods, explicitly call setLogLevel(CloudPushService.LOG_DEBUG).

  • Test notification opened events from both the proprietary channel and vendor channels. Verify that the unified onNotificationOpened callback correctly receives the title, body, and business parameters.

  • Test opening notifications when the application is in the foreground, in the background, or closed (triggering a cold start). Confirm that the business page navigation and back-stack behavior work as expected.

  • In Logcat, filter by the EMAS_PUSH tag. Look for [PopupNotifyClick] and sendNotificationOpenedIntent in the log messages to locate the SDK's click dispatch logs, and then verify your application's business callback.

  • To check logs from the native vendor SDKs and the Android system, filter by their respective tags.