Vendor channel integration use cases

Updated at:

This topic describes a use case that combines a standard push with an auxiliary pop-up, demonstrating how to configure the auxiliary pop-up feature.

Important

This topic describes a common configuration scenario for standard push and an auxiliary pop-up. To handle client-side clicks, see Auxiliary Pop-up Integration (3.x) or Auxiliary Pop-up Integration (4.x) depending on your SDK version.

Client-side configuration

This example uses two client activities, Main and Second. MainActivity is the main entry point of the app, and SecondActivity extends AndroidPopupActivity.

  • Important

    In Android SDK 4.x, MessageReceiver and AliyunMessageIntentService support the following business callbacks:

    • ACCS proprietary channel and FCM: Full business callbacks are supported, including message reception (onMessage), notification received (onNotification), notification opened (onNotificationOpened), and notification cleared (onNotificationRemoved).

    • For Android vendor channels other than FCM: Only onNotificationOpened (notification opened) is supported. Other callbacks, such as for message reception, notification received, or notification cleared, are not triggered.

    The following example shows a callback for a standard notification received event. Add this method to your MessageReceiver subclass. Implement other callbacks as described in the integration guide for your SDK.

    @Override
    public void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
      Log.d(TAG, "Receive notification, title: " + title + ", content: " + summary + ", extraMap: " + extraMap);
    }
  • Define MainActivity:

    package com.alibaba.push.testdemo;
    public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        Log.d(TAG, "Main");
      }
    }
  • Integrate SecondActivity:

    SecondActivity extends AndroidPopupActivity and handles clicks on notifications from vendor channels. Configure the specific implementation and click callbacks as described in the auxiliary pop-up integration guide for your SDK version.

Use case: standard push + auxiliary pop-up

Server-side configuration

Use the following server-side configuration:

PushRequest pushRequest = new PushRequest();
// Other settings are omitted.
// Notification
pushRequest.setPushType("NOTICE");
// Title
pushRequest.setTitle("hello");
// Body
pushRequest.setBody("PushRequest body");
// Action to perform after a notification is opened. Valid values: "APPLICATION" (Open application), "ACTIVITY" (Open AndroidActivity), "URL" (Open URL), and "NONE" (None).
pushRequest.setAndroidOpenType("APPLICATION");
// Activity to open after a notification is opened. This parameter is valid only when AndroidOpenType is set to "ACTIVITY".
pushRequest.setAndroidActivity("com.alibaba.push.testdemo.MainActivity");
// Activity for the auxiliary pop-up to open.
pushRequest.setAndroidPopupActivity("com.alibaba.push.testdemo.SecondActivity");
// Title for the auxiliary pop-up.
pushRequest.setAndroidPopupTitle("hello2");
// Body for the auxiliary pop-up.
pushRequest.setAndroidPopupBody("PushRequest body2");
// Extended parameters for the Android notification.
pushRequest.setAndroidExtParameters("{\"k1\":\"android\",\"k2\":\"v2\"}");

Push results

For online devices and devices not using vendor channels:

  • A notification from the standard push channel is displayed. Opening the notification launches the app and displays the MainActivity homepage. If the app is already in the foreground, the current screen remains unchanged.

  • The onNotification() callback outputs Receive notification, title: hello, content: PushRequest body, extraMap: {k1=android, k2=v2}.

For devices using vendor channels, such as Xiaomi or Huawei, after the app process is terminated:

  • A notification from the vendor channel is displayed. Opening the notification opens SecondActivity.

  • After the auxiliary pop-up parses the click data, the business callback receives the following data: title: hello, content: PushRequest body, and extraMap: {k1=android, k2=v2}. Configure the specific callback as described in the auxiliary pop-up integration guide for your SDK version.

Use case summary

Server-side parameters

  • Title, Body, and AndroidExtParameters apply to all scenarios.

  • AndroidOpenType and AndroidActivity apply to online devices and devices not using vendor channels such as Xiaomi or Huawei.

  • AndroidPopupTitle, AndroidPopupBody, and AndroidPopupActivity apply only to vendor channels.

Client-side data reception

  • For online devices and devices not using vendor channels such as Xiaomi or Huawei, the custom MessageReceiver receives the data.

  • For vendor channels, the AndroidPopupActivity auxiliary pop-up handles notification opened events. Configure the click event handling as described in the auxiliary pop-up integration guide for your SDK version.

Note

For notifications delivered through a vendor channel, the server-side AndroidPopupTitle and AndroidPopupBody parameters set the title and body of the notification. Opening the notification launches the AndroidPopupActivity auxiliary pop-up. The parsed click data contains the original Title, Body, and AndroidExtParameters values from the server-side. Configure the specific business callbacks as described in the auxiliary pop-up integration guide for your SDK version.