TPNS SDK uses an implicit PendingIntent in TPushAlarmManager.set
in the code to trigger SDK internal heartbeats.
You can address the issue by referring to Google's Remediation for Implicit PendingIntent Vulnerability. TPNS SDK has performed the following self-check:
a. The setAction
used is a static broadcast action declared by the SDK and has no exposure risk.
b. The target of the PendingIntent is SDK's internal static broadcast action, and the broadcast permission declared by SDK has been added.
Google's documentation mentions the following: "Fixing this issue is recommended but not mandatory. The publication status of your app will be unaffected by the presence of this issue."
TPNS's current PendingIntent is a trusted and secure PendingIntent, and Google claimed that the issue will not affect the publishing of your application. You can ignore this message and continue to publish your application.
You can set a custom ringtone by creating a notification channel.
n_ch_id
for push. For a vendor channel, you must specify the vendor channel ID. That is, for Huawei channel, specify hw_ch_id
; for Mi channel, specify xm_ch_id
.Note:
- Currently, only Huawei, Mi, FCM, and TPNS channels support custom ringtones.
- Before using the push channels of some vendors, you need to apply for notification classification permissions. For related descriptions and application steps, see Vendor Message Classification Feature Use Instructions.
- For Huawei push channel, if you select China as the data processing location when you apply for the Huawei push service for your application in the Huawei push console, the channel customization feature is no longer applicable to your application. That is, you cannot use the notification channel capability to customize notification ringtones. For more information, see Notification Channel Customization.
To disable the feature, call the following API in onCreate
of Application
or LauncherActivity
during application initialization and pass in false
:
Note:The session keep-alive feature can be disabled only in SDK v1.1.6.0 and later versions. In SDK versions earlier than v1.1.6.0, the feature is enabled by default and cannot be disabled.
XGPushConfig.enablePullUpOtherApp(Context context, boolean pullUp);
If you use Gradle automatic integration, configure the following node under the <application>
tag of the AndroidManifest.xml
file of your application, where xxx
is a custom name. If you use manual integration, modify node attributes as follows:
<!-- Add the following node to the AndroidManifest.xml file of your application, where xxx is a custom name: -->
<!-- To disable the feature of keep-alive with TPNS application, configure as follows: -->
<provider
android:name="com.tencent.android.tpush.XGPushProvider"
tools:replace="android:authorities"
android:authorities="application package name.xxx.XGVIP_PUSH_AUTH"
android:exported="false" />
If the following log is printed in the console, the session keep-alive feature has been disabled: I/TPush: [ServiceUtil] disable pull up other app
For the scenario where the user agrees to the Terms of Service and Privacy Policy, you can add the following node to the AndroidManifest.xml
file so that the push service is not automatically enabled when the application is started for the first time after installation until the push service registration API XGPushManager.registerPush()
is called:
<meta-data
android:name="XG_SERVICE_PULL_UP_OFF"
android:value="true" />
HarmonyOS is fully compatible with the Android SDK, so HarmonyOS users can use the push feature normally.
Vendor | Need to Be Launched to Application Markets |
---|---|
Mi | No. You only need an individual developer account to enable Mi Push. For details, see here. |
Meizu | No. You only need an individual developer account to enable Meizu Push. For details, see here. |
FCM | No. You only need an individual developer account to enable FCM Push. |
Huawei | No. You only need an individual developer account to enable Huawei Push. For details, see here. |
OPPO | Yes. You need an enterprise developer account to enable OPPO PUSH. For details, see here. |
vivo | Yes. You need an enterprise developer account to enable vivo Push. For details, see here. |
After you integrate the push services of the vivo channel, certain security detection tools may prompt that "the application contains unused permission strings". Details are as follows:
Problem source: vivo channel push SDK v2.3.4
Class file involved: com.vivo.push.util.z
; sensitive permission string involved: android.permission.GET_ACCOUNTS
Note:Inspection found that the problem also exists in the vivo channel push SDK v3.0.0.3.
The problem code is from the vivo channel push SDK. The TPNS team is unable to change the code and has been reported the problem to vivo. vivo replied that the relevant static fields are the legacy code of the SDK and are not actually used, and they will schedule to fix the problem as soon as possible. The following is a quick solution for your reference:
XGPushManager.unregisterPush\(this\)
API has been called if the messages cannot be received when the application is launched again.Access ID
and Access Key
are correctly configured. Common errors are that Secret key
is used by mistake or Access Key
contains spaces at the beginning and end.Perform automated troubleshooting with the troubleshooting tool as instructed here. General errors include the following:
TPNS does not support Nubia phones released after 2015, as the new version of Nubia operating system has a super power-saving feature, which will kill background processes very quickly and prevent TPNS Service from being started, resulting in failures of registration with Nubia phones.
Starting from TPNS SDK v1.1.6.3, in order to avoid the situation where push services of other vendors auto-start and transfer user data on the background on a phone, push service components of other vendors will be disabled on the phone.
Huawei uses some public components for different features such as account, game, and push. Disabling the push component by TPNS may make other service features unable to start on a non-Huawei phone. If you need to turn off this disablement feature, you can configure the following:
Add the following node configuration under the application
tag of the AndroidManifest.xml
file, uninstall the application, and reinstall it.
<meta-data
android:name="tpns-disable-component-huawei-v2"
android:value="false" />
<meta-data
android:name="tpns-disable-component-huawei-v4"
android:value="false" />
You can redirect subscribers who click your notification to a specified in-app page, HTML5 page, or Deeplink to meet your needs in different use cases. For more information, please see Notification Tap-to-Redirect.
Callback | Arrival Callback | Click Callback |
---|---|---|
Mi | Not supported | Supported |
Meizu | Not supported | Supported |
FCM | Not supported | Supported |
Huawei | Not supported | Supported |
OPPO | Not supported | Supported |
vivo | Not supported | Supported |
Note:Click callback of vendor channels is supported by SDK v1.2.0.1 and above. Legacy versions support this feature only for Huawei, Mi, Meizu, and vivo.
title
and content
obtained by onNotifactionClickedResult
and onNotificationShowedResult
are empty when the application is closed?For pushes through vendor channels, title
and content
are concatenated in intent
and delivered. Therefore, they cannot be obtained by the onNotifactionClickedResult
and onNotificationShowedResult
methods. To obtain the two parameters, you need to use the Intent mode. For more information, please see Notification Tap-to-Redirect.
other push Token
that occurs during debugging after my application is integrated with a vendor channel?Check whether the application operation logs contain information similar to the following:
[OtherPushClient] handleUpdateToken other push token is : other push type: huawei
If such log information exists, it means that your application failed to register with the vendor channel. In that case, get the return code for vendor channel registration failure to locate and troubleshoot the problem. For more information, please see Troubleshooting Vendor Channel Registration Failures.
Currently, IM uses the vendor JAR packages provided by TPNS. Please replace the relevant dependency packages according to the following table to fix the problem.
Push Channel | System Requirement | Condition Description |
---|---|---|
Mi Push | MIUI | To use Mi Push, add the following dependency: implementation 'com.tencent.tpns:xiaomi:1.2.1.3-release' |
Huawei Push | EMUI | To use Huawei Push, add the following dependencies:implementation 'com.tencent.tpns:huawei:1.2.1.3-release' implementation 'com.huawei.hms:push:5.0.2.300' |
Google FCM Push | Android 4.1 and above | The mobile phone needs to install Google Play Services and be used outside the Chinese mainland. Add the following dependency: implementation 'com.google.firebase:firebase-messaging:20.2.3' |
Meizu Push | Flyme | To use Meizu Push, add the following dependency: implementation 'com.tencent.tpns:meizu:1.2.1.3-release' |
OPPO PUSH | ColorOS | Not all OPPO models and versions support OPPO PUSH. To use OPPO PUSH, add the following dependency: implementation 'com.tencent.tpns:oppo:1.2.1.3-release' |
vivo Push | FuntouchOS | Not all vivo models and versions support vivo Push. To use vivo Push, add the following dependency: implementation 'com.tencent.tpns:vivo:1.2.1.3-release' |
target sdk
is greater than or equal to 21, causing the icon to be gray.target sdk
to below 21. If you don't want target sdk
to be below 21, you can rename a small transparent background .png image to notification_icon.png
(the filename must be unique) and place it in the drawable
directory; in this way, the small icon will be displayed as gray (but shaped).notification_icon.png
small icon resource will only take effect directly on Google Pixel phones by default. To achieve such small icon effect for custom notifications on other phones, you need to specify the resource filename (without the extension) as the message.android.small_icon
field in the push API. In addition, the custom notification small icon supports solid colors by specifying a decimal value of an RGB color as the message.android.icon_color
field in the push API.Below is an example of push API fields, where icon_color: 123456
indicates the RGB color 01e240:
{
"message": {
"android": {
"small_icon": "notification_icon",
"icon_color": 123456
}
}
}
The display effect after adaption is as shown below. We recommend you draw an icon based on the demo logo.
Note:
- The small icon must be a PNG image with an alpha channel.
- The background must be transparent.
- Do not leave too much padding around the icon.
- We recommend you use an image with dimensions of 46x46, as smaller images will be blurry, while larger images will be automatically scaled down.
In the above two cases, you need to place an image exactly named stat_sys_third_app_notify
in the drawable
folders with different resolutions. The image is stored in the flyme-notification-res
folder of the Meizu vendor dependency directory of TPNS Android SDK.
debug
field in the tpns-configs.json
file to true
and run the following command: ./gradlew --rerun-tasks :app:processReleaseManifest
Then, use the TpnsPlugin
keyword for analysis.
2. Click the sync projects icon.
3. Check whether relevant dependencies exist in External Libraries of the project.
Add the following attributes to the gradle.properties
file of the AndroidX project:
android.useAndroidX=trueandroid.enableJetifier=true
Note:
android.useAndroidX=true
: to enable AndroidX for the current project.android.enableJetifier=true
: to migrate the dependency package to AndroidX.
After you integrate the push services of various vendor channels, certain security detection tools may prompt that "the application transferred information over HTTP in plaintext". HTTP addresses involved are as follows:
http://new.api.ad.xiaomi.com/logNotificationAdActions,http://resolver.msg.xiaomi.net/psc/?t=a
http://norma-external-collect.meizu.com/android/exchange/getpublickey.do,http://norma-external-collect.meizu.com/push/android/external/add.do
All the above HTTP URLs are from the push SDKs of relevant vendors. The TPNS team is unable to clarify their purposes or control their behaviors but is actively contacting them and promoting the adoption of transfer over HTTPS. Currently, you should evaluate and choose whether to continue to use the above vendors' push services.
If the number of loaded methods in the project exceeds 65,000, please create subpackages for the project.
Activity
page but it often cannot be redirected to normally?On some phones, redirection upon click on the notification bar may experience permission issues.
Solution: in androidManifest.xml
, add android:exported="true"
to the Activity
to be opened.
The registration method can be called anywhere, but applicationContext must be input.
Was this page helpful?