TPNS enables the keep-alive feature by default. Please call the following API in onCreate
of Application
or LauncherActivity
during application initialization and pass in a false
value:
XGPushConfig.enablePullUpOtherApp(Context context, boolean pullUp);
If you use the automatic gradle integration method, please configure the following node under the AndroidManifest.xml
file of your application, where xxx
is a custom name. If you use manual integration, please modify the 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, please configure -->
<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
.
Access ID
and Access Key
are correctly configured. Common errors are that the Secret key
is misused or the Access Key
contains spaces.Please perform automated troubleshooting with the troubleshooting tool as instructed here. General errors include the following:
XGPushManager.unregisterPush\(this\)
API has been called if the messages cannot be received when the application is launched again.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" />
TPNS recommends using Intent for redirection (note: the SDK supports click events by default upon message click, and the corresponding homepage will be opened. If the redirection operation is set in onNotifactionClickedResult
, it will conflict with the custom redirection specified in the console/API, resulting in failure of the custom redirection).
Guide for redirection through Intent:
You need to configure the page to redirect to in the client app's manifest:
AboutActivity
, use the following sample code:<activity
android:name="com.qq.xg.AboutActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<!-- Specify your complete scheme by customizing the content of the data block. According to your configuration, a URL identifier in the format of "semantic name://host name/path name" will be formed -->
<!-- To avoid conflicts with the redirect destination pages of other applications, you can use fields that can uniquely identify the application for configuration, such as those with the application name or application package name -->
<data
android:scheme="Semantic name"
android:host="Host name"
android:path="/Path name" />
</intent-filter>
</activity>
If you use the TPNS Console to set the intent for redirect, enter in the following way:
If you use a server SDK, you can set the intent for redirect as follows (with the SDK for Java as an example):
action.setIntent("xgscheme://com.tpns.push/notify_detail");
If you want to bring parameters such as param1
and param2
, you can set as follows:
action.setIntent("xgscheme://com.tpns.push/notify_detail?param1=aa¶m2=bb");
Get the parameters on the device:
onCreate
method of the page you specify for redirect to, add the following code:Uri uri = getIntent().getData();
if (uri != null) {
String url = uri.toString();
String p1= uri.getQueryParameter("param1");
String p2= uri.getQueryParameter("param2");
}
Uri uri = getIntent().getData();
if (uri != null) {
String url = uri.toString();
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setUnregisteredParameterValueSanitizer(UrlQuerySanitizer.getAllButNulLegal());
sanitizer.parseUrl(url);
String value1 = sanitizer.getValue("key1");
String value2 = sanitizer.getValue("key2");
Log.i("TPNS" , "value1 = " + value1 + " value2 = " + value2);
}
Callback | Arrival Callback | Click Callback |
---|---|---|
Mi | Supported | Supported |
Meizu | Supported | Supported |
FCM | 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 only supports this feature for Huawei, Mi, Meizu, and Vivo.
other push Token
that occurs during debugging after my application is integrated with a vendor channel?A log similar to the following one is found in the application operation logs:
[OtherPushClient] handleUpdateToken other push token is : other push type: huawei
Then it means that your application failed to register with the vendor channel. You can locate and troubleshoot the problem by getting the return code for vendor channel registration failure. 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 Requirements | 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 device needs to have Google Play Services installed and use it 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' |
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. For more information, please see the flyme-notification-res
folder in the TPNS SDK for Android.
"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.Add the following property to the gradle.properties
file of the AndroidX project:
android.useAndroidX=trueandroid.enableJetifier=true
Note:
android.useAndroidX=true
indicates to enableAndroidX
for the current project.android.enableJetifier=true
indicates to migrate the dependency package toAndroidX
.
After you integrate the push services of various vendor channels, some security detection tools may prompt that "the application transfers information over HTTP in plaintext". The specific HTTP addresses include:
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
Was this page helpful?