Configure custom redirects for message alerts

Updated at:

When users receive an alert push notification on their app, you can develop and set a custom URL. This allows users to tap the notification and be redirected to the alert details page. This feature is available only for proprietary apps in proprietary brand projects and currently supports only Android devices.

Configure a redirect address

  1. Log on to the IoT Living Platform console.
  2. Go to the Human-Computer Interaction page for your product.
  3. In the navigation pane on the left, click Device Alerting.
  4. Click Create Alert Rule.
  5. In the Create Alert dialog box, enter the URL you developed.
    Note Currently, only proprietary apps support custom redirect addresses for alert push notifications. The Cloud Intelligence App does not support this feature.

    This feature is currently supported on Huawei, Xiaomi, OPPO, and vivo phones. It is not supported on Samsung and Google phones.

  6. Click OK to complete the configuration.

Proprietary app development

  • When a user taps a push notification in an Android app, the app can redirect to a specified activity. The push notification's extension fields include the iotId and openPath fields.
  • In iOS apps, the extension fields of a received push notification include the iotId and openPath fields. The iOS developer can use openPath to determine which page to open.
    { 
     "iotId":"hb6E********B000000", 
     "openPath":"com.aliyun.iot.NotifyTestFirstActivity"
    }

SDK upgrade

Receiving extension fields for offline push notifications on Android requires an upgrade to the app's SDK.

Required push SDK version: com.aliyun.iot.aep.sdk:push:1.0.6.8

The offline redirect page must inherit from BaseNotifyClickActivity. The class name path must match the class name sent by the backend. For example, if the backend passes the class name com.aliyun.iot.NotifyTestFirstActivity, the full class name in the app must also be com.aliyun.iot.NotifyTestFirstActivity. Override the onMessage method to retrieve data. The following example shows how to retrieve data in the onMessage method:

public class NotifyTestFirstActivity extends BaseNotifyClickActivity {
            private static final String TAG = "NotifyTestFirstActivity";
            private final static String PRE_NOTIFY = "Inside NotifyTestFirstActivity test notification click interface: ";
            public static TextView mTextView;
            @Override
            protected void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            setContentView(R.layout.activity_notify_clicked);
            mTextView = findViewById(R.id.text);
            mTextView.setText(PRE_NOTIFY);
            ILog.d(TAG, "onCreate isPushInit = " + PushInitStatus.getInstance().isInitPush);
            }
            @Override
            public void onMessage(Intent intent) {
            runOnUiThread(() -> {
            if (intent != null) {
            String body = intent.getStringExtra(AgooConstants.MESSAGE_BODY); // Get the message content from the third-party channel's hosted pop-up.
            ILog.d(TAG, "onMessage : " + body);
            mTextView.setText(PRE_NOTIFY + body);
                 }
              });
             }
            }