Android Notification Click — Jump Configuration

Last updated:2022-06-08
Expand all
Android Notification Click — Jump Configuration

This article explains how to use intent, deeplink, or "open app" to jump to a target page when a notification has a target destination. We strongly recommend upgrading the SDK to 4.6.0 or later and configuring intent for the notification jump.

  • For SDK < 4.6.0, the Jiguang channel has an onNotifyMessageOpened click callback, but vendor channels do not.
  • For SDK ≥ 4.6.0, Android Jiguang and vendor channels are unified: when there is no notification jump destination, the onNotifyMessageOpened click callback is delivered; when there is a destination, the click callback is not delivered.

Supported versions

The intent field in the REST API covers intent, deeplink, and "open app" jump methods.

  • For SDK < 4.2.2, the intent value only takes effect on the ASUS channel and the Jiguang channel; it does not affect other vendor channels.
  • For SDK ≥ 4.2.2, fill in the intent field when calling the API; otherwise clicking the notification may produce no jump.

How a target destination is configured

"Configuring a notification jump target" means completing the configuration below in the console or the API when sending.

Console

On the send page, select any option under "Android — Click Notification to Open".

API

When sending via the API, set intent, or uri_activity / uri_action, under notification.android.

  • For SDK ≥ 4.2.2, only intent is needed.
  • For SDK < 4.2.2 that previously used uri_activity and uri_action, just set those two fields.
Key Type Required Meaning Description
intent JSON Object Optional Specifies the target page Use intent.url to specify the page to open when the notification is tapped.
  • For SDK < 4.2.2, this only applies to the ASUS channel and the Jiguang channel; it does not affect other vendor channels.
  • For SDK ≥ 4.2.2, fill in this field; otherwise clicking the notification may produce no jump. Three forms are supported:
    1. Jump to a target page:
    intent:#Intent;action=<action path>;component=<package>/<full Activity name>;end
    (OPPO and FCM require an action path; other vendors require the full Activity name. Otherwise the jump fails on that vendor's channel.)
    2. Jump to a deeplink URL:
    scheme://test?key1=val1&key2=val2
    3. Open the app's home page: intent:#Intent;action=android.intent.action.MAIN;end (use exactly this string)
  • uri_activity string Optional Specifies the target page
  • The Activity to open, value is the android:name of the <activity> node.
  • Used for Huawei, Xiaomi, vivo vendor channels.
  • For JPush SDK ≥ V4.2.2, this field is optional; just set intent.
  • uri_action string Optional Specifies the target page
  • The Activity to open, value is the android:name of the <activity><intent-filter><action> node.
  • Used for OPPO and FCM channels.
  • For JPush SDK ≥ V4.2.2, this field is optional; just set intent. Required only if you need backwards compatibility with older SDKs.
  • Format

    Fixed format: intent:#Intent;action="<action path>";component="<package>"/"<Activity component path>";end

    • The URI must start with intent:#Intent; and end with ;end.
    • There must not be multiple action= or component= segments.

    Example:

    intent:#Intent;action=cn.jiguang.myaction;component=cn.jiguang.jumptest/cn.jiguang.jumptest.OpenClickActivity;end
              intent:#Intent;action=cn.jiguang.myaction;component=cn.jiguang.jumptest/cn.jiguang.jumptest.OpenClickActivity;end
    
            
    This code block is shown in the floating window

    With parameters: intent:#Intent;action="<action path>";component="<package>"/"<Activity component path>";S.key1=value1;i.key2=2;end

    • S.: indicates that the value is a String.
    • i.: indicates that the value is an Int.

    Example:

    intent:#Intent;action=cn.jiguang.myaction;component=cn.jiguang.jumptest/cn.jiguang.jumptest.OpenClickActivity;S.key1=value;i.key2=2;end
              intent:#Intent;action=cn.jiguang.myaction;component=cn.jiguang.jumptest/cn.jiguang.jumptest.OpenClickActivity;S.key1=value;i.key2=2;end
    
            
    This code block is shown in the floating window

    Client-side configuration

    Configure the following in AndroidManifest.

    OPPO and FCM channels require both action and category for the jump to work.

    <activity android:name="cn.jiguang.jumptest.OpenClickActivity" android:exported="true" android:launchMode="singleTask" android:screenOrientation="portrait"> <intent-filter> <action android:name="cn.jiguang.myaction" ></action> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
              <activity
     android:name="cn.jiguang.jumptest.OpenClickActivity"
     android:exported="true"
     android:launchMode="singleTask"
     android:screenOrientation="portrait">
     <intent-filter>
     <action android:name="cn.jiguang.myaction" ></action>
     <category android:name="android.intent.category.DEFAULT" />
     </intent-filter>
    </activity>
    
            
    This code block is shown in the floating window

    Server-side usage

    Console

    Go to Message Push → Push Management → Create Push, choose the Android platform, select "intent (recommended)" under "Android — Click Notification to Open", and fill in the intent.

    API

    • For SDK ≥ 4.2.2, only intent is needed; see API usage.
    • For SDK < 4.2.2 that previously used uri_activity and uri_action, just set those two fields.
    { "notification": { "android": { "alert": "hello, JPush!", "title": "JPush test", "intent": { "url": "intent:#Intent;action=cn.jiguang.myaction;component=cn.jiguang.jumptest/cn.jiguang.jumptest.OpenClickActivity;S.key1=value;i.key2=3;end" }, "uri_activity": "cn.jiguang.jumptest.OpenClickActivity",// compat for < 4.2.2 "uri_action": "cn.jiguang.jumptest.OpenClickActivity"// compat for < 4.2.2 } } }
              {
     "notification": {
     "android": {
     "alert": "hello, JPush!",
     "title": "JPush test",
     "intent": {
     "url": "intent:#Intent;action=cn.jiguang.myaction;component=cn.jiguang.jumptest/cn.jiguang.jumptest.OpenClickActivity;S.key1=value;i.key2=3;end"
     },
     "uri_activity": "cn.jiguang.jumptest.OpenClickActivity",// compat for < 4.2.2
     "uri_action": "cn.jiguang.jumptest.OpenClickActivity"// compat for < 4.2.2
    
     }
     }
    }
    
            
    This code block is shown in the floating window

    Reading intent parameters on the client

    • To jump to a specific position within a page, the push can carry custom parameters; read them and run your business logic.
    • The SDK passes intent parameters through as-is, so just read them from the target Activity's intent.
    package cn.jiguang.jumptest; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.util.Log; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); handleIntent(); } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); handleIntent(); } void handleIntent(){ if(getIntent()!=null){ String value1 =getIntent().getStringExtra("key1"); int value2 =getIntent().getIntExtra("key2",0); Log.e("MainActivity",""+value1); Log.e("MainActivity",""+value2); } } }
              package cn.jiguang.jumptest;
    import androidx.appcompat.app.AppCompatActivity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    
    public class MainActivity extends AppCompatActivity {
    
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
     handleIntent();
     }
    
     @Override
     protected void onNewIntent(Intent intent) {
     super.onNewIntent(intent);
     handleIntent();
     }
     void handleIntent(){
     if(getIntent()!=null){
     String value1 =getIntent().getStringExtra("key1");
     int value2 =getIntent().getIntExtra("key2",0);
     Log.e("MainActivity",""+value1);
     Log.e("MainActivity",""+value2);
     }
     }
    }
    
            
    This code block is shown in the floating window

    Reading Extras on the client

    To jump to a specific position within a page, the push can carry custom parameters; read them and run your business logic.

    • For SDK < 4.6.0, the Jiguang channel has an onNotifyMessageOpened click callback, but vendor channels do not.
    • For SDK ≥ 4.6.0, Android Jiguang and vendor channels are unified: when there is no notification jump destination, onNotifyMessageOpened is delivered; when there is a destination, the callback is not delivered.
    1. With a notification jump destination:
    • SDK < 4.6.0
    • Huawei channel: use getIntent().getData().toString() to read parameters.
    • Xiaomi, vivo, OPPO, FCM, Meizu channels: use getIntent().getExtras().getString("JMessageExtra").
    • Jiguang channel: read parameters from the message in the onNotifyMessageOpened(Context context, NotificationMessage message) callback.
    • SDK ≥ 4.6.0
    • Huawei channel: use getIntent().getData().toString().
    • Xiaomi, vivo, OPPO, FCM, Meizu, Honor, Jiguang channels: use getIntent().getExtras().getString("JMessageExtra").
    1. Without a notification jump destination:

      Note:

      • When REST API does not set intent, onNotifyMessageOpened is delivered.
      • In the console, selecting "intent" but leaving the parameter empty also triggers onNotifyMessageOpened. Other configurations set a notification target and do not deliver onNotifyMessageOpened. See How a target destination is configured.
    • SDK < 4.6.0:
    • Vendor channels have no click callback; clicks do not jump, and parameters cannot be obtained.
    • Jiguang channel: read parameters from the message in onNotifyMessageOpened(Context context, NotificationMessage message).
    • SDK ≥ 4.6.0: all channels read parameters from the message in onNotifyMessageOpened(Context context, NotificationMessage message).

    Example:

    package com.HuananThirdPush.cn; import android.app.Activity; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.widget.TextView; import org.json.JSONException; import org.json.JSONObject; import cn.jpush.android.api.JPushInterface; public class OpenClickActivity extends Activity { private static final String TAG = "OpenClickActivity"; /** Notification extras key **/ private static final String KEY_EXTRAS = "n_extras"; private TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTextView = new TextView(this); setContentView(mTextView); handleOpenClick(); } /** * Handle click events. The configured launch Activity is always started with * Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK, * so calling this in onCreate is enough. */ private void handleOpenClick() { Log.d(TAG, "User clicked the notification"); String data = null; // Huawei platform jpush payload if (getIntent().getData()!= null) { data = getIntent().getData().toString(); } // FCM / OPPO / Xiaomi / vivo / Meizu / Honor platform jpush payload if (TextUtils.isEmpty(data) && getIntent().getExtras()!= null) { data = getIntent().getExtras().getString("JMessageExtra"); } Log.w(TAG, "msg content is " + String.valueOf(data)); if (TextUtils.isEmpty(data)) return; try { JSONObject jsonObject = new JSONObject(data); String extras = jsonObject.optString(KEY_EXTRAS); StringBuilder sb = new StringBuilder(); sb.append("extras:"); sb.append(String.valueOf(extras)); sb.append("\n"); mTextView.setText(sb.toString()); } }
              package com.HuananThirdPush.cn;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.text.TextUtils;
    import android.util.Log;
    import android.widget.TextView;
    import org.json.JSONException;
    import org.json.JSONObject;
    import cn.jpush.android.api.JPushInterface;
    
    public class OpenClickActivity extends Activity {
     private static final String TAG = "OpenClickActivity";
     /** Notification extras key **/
     private static final String KEY_EXTRAS = "n_extras";
     private TextView mTextView;
    
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     mTextView = new TextView(this);
     setContentView(mTextView);
     handleOpenClick();
     }
    
     /**
     * Handle click events. The configured launch Activity is always started with
     * Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK,
     * so calling this in onCreate is enough.
     */
     private void handleOpenClick() {
     Log.d(TAG, "User clicked the notification");
     String data = null;
    
     // Huawei platform jpush payload
     if (getIntent().getData()!= null) {
     data = getIntent().getData().toString();
     }
    
     // FCM / OPPO / Xiaomi / vivo / Meizu / Honor platform jpush payload
     if (TextUtils.isEmpty(data) && getIntent().getExtras()!= null) {
     data = getIntent().getExtras().getString("JMessageExtra");
     }
    
     Log.w(TAG, "msg content is " + String.valueOf(data));
     if (TextUtils.isEmpty(data)) return;
     try {
     JSONObject jsonObject = new JSONObject(data);
     String extras = jsonObject.optString(KEY_EXTRAS);
     StringBuilder sb = new StringBuilder();
     sb.append("extras:");
     sb.append(String.valueOf(extras));
     sb.append("\n");
     mTextView.setText(sb.toString());
    
     }
    }
    
            
    This code block is shown in the floating window

    Format

    Fixed format:

    • scheme://
    • scheme://host
    • scheme://host/path

    With parameters:
    scheme://host/path?key1=val1&key2=val2

    Client-side configuration

    Configure the following in AndroidManifest.

    • action and category must match the example below.
    • data.scheme is required; other attributes are optional.
    <activity android:name=".DeeplinkTestActivity"> <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:scheme="jiguang" android:host="deeptest" android:path="/index"/> </intent-filter> </activity>
              
    <activity android:name=".DeeplinkTestActivity">
     <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:scheme="jiguang"
     android:host="deeptest"
     android:path="/index"/>
     </intent-filter>
    </activity>
    
            
    This code block is shown in the floating window

    Server-side usage

    Console

    Go to Message Push → Push Management → Create Push, choose the Android platform, and select "DeepLink" under "Android — Click Notification to Open"; fill in the DeepLink.

    API

    • For SDK ≥ 4.2.2, only intent is needed; see API usage.
    • For SDK < 4.2.2 that previously used uri_activity and uri_action, just set those two fields.
    { "notification": { "android": { "alert": "hello, JPush!", "title": "JPush test", "intent": { "url": "jiguang://deeptest/index?key1=val1&key2=val2" }, "uri_activity": "cn.jiguang.jumptest.DeeplinkTestActivity",// compat for < 4.2.2 "uri_action": "cn.jiguang.jumptest.DeeplinkTestActivity"// compat for < 4.2.2 } } }
              {
     "notification": {
     "android": {
     "alert": "hello, JPush!",
     "title": "JPush test",
     "intent": {
     "url": "jiguang://deeptest/index?key1=val1&key2=val2"
     },
     "uri_activity": "cn.jiguang.jumptest.DeeplinkTestActivity",// compat for < 4.2.2
     "uri_action": "cn.jiguang.jumptest.DeeplinkTestActivity"// compat for < 4.2.2
    
     }
     }
    }
    
            
    This code block is shown in the floating window

    Open app

    API

    Console

    Go to Message Push → Push Management → Create Push, choose the Android platform, and select "Open app" under "Android — Click Notification to Open".

    API

    • For SDK ≥ 4.2.2, only intent is needed; see API usage.
    • For SDK < 4.2.2 that previously used uri_activity and uri_action, just set those two fields.
    { "notification": { "android": { "alert": "hello, JPush!", "title": "JPush test", "intent": { "url": "intent:#Intent;action=android.intent.action.MAIN;end" }, "uri_activity": "cn.jiguang.jumptest.MainActivity", // compat for < 4.2.2 "uri_action": "cn.jiguang.jumptest.MainActivity" // compat for < 4.2.2 } } }
              {
     "notification": {
     "android": {
     "alert": "hello, JPush!",
     "title": "JPush test",
     "intent": {
     "url": "intent:#Intent;action=android.intent.action.MAIN;end"
     },
     "uri_activity": "cn.jiguang.jumptest.MainActivity", // compat for < 4.2.2
     "uri_action": "cn.jiguang.jumptest.MainActivity" // compat for < 4.2.2
     }
     }
    }
    
            
    This code block is shown in the floating window
    Was this document helpful?

    Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

    Open in Docs Center