Integrate Baidu Plugin

Follow the steps below to get your Android application ready to receive pushes through Baidu

Before you proceed with plugin integration, make sure your Baidu platform is configured according to Baidu Configuration Guide.

Resources:

Important! Installing this plugin will fully switch your Android app from FCM to Baidu for push notifications. This will be addressed in future releases. In the meantime, please consider creating a separate build for Chinese market.

1. Download Baidu SDK from Baidu Cloud Push portal.

2. Extract pushservice-#.#.#.##.jar (where #.#.#.## is the library version) from libs folder of Baidu SDK and place it to app/libs folder of your project.

3. From the same libs folder of Baidu SDK, extract all subfolders (arm64-v8a, x86 and others) and place them to app/jniLibs folder of your project.

4. Include the following lines into android section of app/build.gradle:

build.gradle
android {
...
sourceSets {
main {
jniLibs.srcDirs = ['jniLibs']
}
}
}

5. Include the following lines into dependencies section of app/build.gradle:

build.gradle
implementation 'com.pushwoosh:pushwoosh-baidu:+'

6. In the same app/build.gradle, change the targetSdkVersion to 25.

7. Add the following permissions to your AndroidManifest.xml:

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="baidu.push.permission.WRITE_PUSHINFOPROVIDER.${applicationId}" />
<permission
android:name="baidu.push.permission.WRITE_PUSHINFOPROVIDER.${applicationId}"
android:protectionLevel="signature">
</permission>

8. Include the following lines into application section of AndroidManifest.xml:

AndroidManifet.xml
<receiver android:name="com.baidu.android.pushservice.PushServiceReceiver" android:process=":bdservice_v1">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="com.baidu.android.pushservice.action.notification.SHOW" />
<action android:name="com.baidu.android.pushservice.action.media.CLICK" />
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
<receiver android:name="com.baidu.android.pushservice.RegistrationReceiver" android:process=":bdservice_v1">
<intent-filter>
<action android:name="com.baidu.android.pushservice.action.METHOD" />
<action android:name="com.baidu.android.pushservice.action.BIND_SYNC" />

9. In the same application section of AndroidManifest.xml, include the following metadata:

AndroidManifest.xml
<meta-data android:name="com.pushwoosh.appid" android:value="your_pushwoosh_application_id" />
<meta-data android:name="com.pushwoosh.baidu_api_key" android:value="your_baidu_api_key" />

Where:

  • com.pushwoosh.appid is your Pushwoosh Application Code (e.g. DEAD0-BEEF0)

  • com.pushwoosh.baidu_api_key is an API key for your Baidu project