Get the payload field
Introduction
The offline push sender sends additional information to the receiver by configuring the payload parameter of ZIMPushConfig (the version before 2.5.0 is the extendedData parameter). When the receiver needs to use the ZPNs SDK, the payload in the extras of the push channel field to get this information.
This document introduces how to use the ZPNs SDK interface to obtain the payload transparent transmission field.
Warning
The ZPNs SDK must be used with ZIM SDK 2.0.0 or later.
Prerequisites
- Integrate the ZPNs SDK. For more, refer to the Implement offline push notification.
Common Usage
- In the AndroidManifest.xml file, set the exported attribute of the main Activity to true, and configure the intent-filter.
Untitled
<activity
android:name="The main Activity path of your project"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
1
- The developer obtains the data in the
onCreate
oronNewIntent
of the main Activity through the following methods.
Untitled
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String payload = getIntent().getExtras().getString("payload");
}
1