Android FAQs

Last updated: 2020-02-25 17:50:12

PDF

Why can't I get the push message?

Login Tencent Mobile push console To use the acquired Token for push If you cannot receive the push, please check according to the following circumstances:

  • Please make sure that the SDK version is the latest version. If there is a problem with the old version, it may have been fixed in the new version.
  • If you encounter a push error on the Web side, please refresh the page and try again.

Why can't I receive a push after registering successfully?

  • Please check whether the current application package name is inconsistent with Enter's application package name when registering Tencent mobile push application. If it is inconsistent, it is recommended to enable multiple package name push.

  • Check whether the mobile network has any exceptions and switch to 4G network for testing.

  • TPNS push includes "notification panel message" and "in-app message" (passthrough message). A notification panel message can be displayed in the notification panel, while an in-app message cannot.

  • Confirm that the phone is in normal mode. In low power or do not disturb mode, some phones may restrict the network and activity of the backend TPNS process.

  • Check whether notification panel message is allowed on the phone. On OPPO and Vivo phones, you have to manually allow the notification.

Why Device failed to register?

  • Data synchronization for newly created app will take about one minute. During this period, the registration may return the error code 20. You can retry later.

  • Check whether the access id and access key are correctly configured. Common errors are that secret key is misused or access key contains spaces.

  • Registration returned error If the console returns error codes such as 10004, 10002, 20, etc., see Android SDK error code .
    Check the current network condition. We recommend you use 4G network for testing. Wi-Fi used by many users may have insufficient network bandwidth.

  • Nubia brand mobile phone Machines released in the second half of 2015 and 2016 cannot be registered. Model includes NubiaZ11 series, NubiaZ11S series and NubiaZ9S series.

Why can't I receive a push after shutting down the application?

  • At present, there is no guarantee that third-party push will still receive push messages after the application is closed. This problem is the restriction of customized ROM on Tencent Mobile push Service. All activities of Tencent Mobile push need to be established on the basis that the Service of Tencent Mobile push can run on the network. After the Service is terminated, it is limited by the system, security software and user operation whether Launch can be used again.

  • QQ and WeChat are system-level app whitelist, and the relevant service will not terminate after you exit the app, so the user can still receive messages after exiting the app, and the relevant service can still survive in the backend.

  • In Android, after you exit the app and the TPNS service is disconnected from the TPNS server, messages delivered to the device will become offline messages, which can be retained for up to 72 hours. If there are multiple offline messages, only two can be retained in each device. If messages are pushed after the app is closed, please check whether the unregistration API has been called if you cannot receive the message when launching the app: XGPushManager.unregisterPush (this )。

How do I set up a message click event?

In SDK, a click on a message can trigger a click event, which by default opens the main interface. Therefore, if a redirect action is configured in OnNotificationClickedResult Callback method on the device, there is a conflict between the custom redirect and the default click event. The user will be redirected to the specified page and then to the main page. Thus, you cannot configure redirect in OnNotificationClickedResult .

Use Intent to redirect to the specified page
On the manifest of the client App, configure the page that requires Redirect:

  • If you want Redirect AboutActivity to specify a page, the sample code is as follows:
<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"/>
<data android:scheme="xgscheme"
android:host="com.xg.push"
android:path="/notify_detail" />
</intent-filter>
</activity>
  • If you use Tencent Mobile push console to set Intent to perform Redirect, Enter uses the following ways:

  • If you use the server SDK to set the intent for redirection, you can set the intent as (take Java SDK as an example):

action.setIntent("xgscheme://com.xg.push/notify_detail");
  • If you need to take parameters such as param1 and param2, you can set them as follows:
action.setIntent("xgscheme://com.xg.push/notify_detail?param1=aa&param2=bb");

Get the parameters on the device:

  1. In the page onCreate method specified by Redirect, 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");
 }
  1. If the passed parameter contains special characters, such as #, &, etc., you can parse it in the following way:
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("XG" , "value1 = " + value1 + " value2 = " + value2);
}

What does Vendor channel's callback support?

  • Mi channel supports arrival callback and passthrough, but not tap callback.
  • Huawei channel supports tap callback (requiring custom parameters) and passthrough (ignoring custom parameters), but not arrival callback.
  • Meizu channel supports arrival callback and tap callback, but not passthrough.
  • Meizu channel supports arrival callback and tap callback, but not passthrough.
  • OPPO channel does not support click and arrival callback, and does not support pass through

If you need to obtain parameters or Redirect custom page by clicking callback, you can do so by using Intent.

How to solve the problem of otherpushToken = null encountered in the process of debugging?

Troubleshooting for Mi channel

  • Check whether the App package name matches the package name of Xiaomi's open push platform.

  • Check whether the message push service is enabled on Xiaomi's open push platform.

  • Check the manifest file configuration according to the development documentation, especially the places where the package name needs to be modified.

<permission android:name="com.example.mipushtest.permission.MIPUSH_RECEIVE" android:protectionLevel="signature" />
<!-- Here, change com.example.mipushtest to the app package name -->
<uses-permission android:name="com.example.mipushtest.permission.MIPUSH_RECEIVE" />
<!-- Here, change com.example.mipushtest to the app package name -->
  • Check whether you have set the APPID and APPKEY of Mi before the registration and whether the third-party push has been started.
// Enable the third-party push
XGPushConfig.enableOtherPush(this,true);
// Set the Appid and Appkey of Mi
XGPushConfig.setMiPushAppId(this,MIPUSH_APPID);
XGPushConfig.setMiPushAppKey(this,MIPUSH_APPKEY);
  • Listen to the registration result of Mi by implementing the custom broadcast that inherits PushMessageReceiver and check the registration return code.
  • Start logcat, observe the log with the tag of PushService to see what error message is present.

Troubleshooting for Huawei channel

  • Check whether the TPNS SDK is v3.2.0 or higher and whether the version in Settings -> Application Management -> Huawei Mobile Service On the Huawei phone is higher than 2.5.3.

  • Check to see if it is a signed package.

  • Whether Huawei's official website is equipped with SHA256 certificate fingerprint.

  • Check the manifest file configuration according to the Huawei channel access guide in the development documentation.

  • Check whether the third-party push has been started before the TPNS registration and whether the Huawei APPID is configured correctly.

  • Whether the package name of App is the same as that of Huawei push official website and Tencent Mobile push Management console.

  • Call XGPushConfig.setHuaweiDebug (true ) before registering the code, manually confirm that the storage permission is granted to the app, check the reason of error of Huawei registration failure outputted in the huawei.txt file in the SD card directory, and then find the cause corresponding to the error code in Huawei development documentation.

  • In cmd, run adb shell setprop log.tag.hwpush VERBOSE and
    Adb shell logcat-v time > D:/log.txt to start to capture the log, test, and then close the command window.

Troubleshooting for Meizu channel

Similar to the troubleshooting method for Mi channel. For more information, see troubleshooting for Mi channel.

Meizu Flyme6.0 and lower versions of mobile phones, why does the message arrive at Device but not displayed in the notification bar?

High-version Meizu phones no longer need to set a status bar icon. If the Android SDK version is less than 1.1.4.0, please place an image whose name must be stat_sys_third_app_notify in the corresponding drawable folder with different resolutions.

How to solve component dependency conflicts when integrating Huawei to push channel?

The project uses Huawei games, payments, accounts and other service components. If you encounter component dependency conflicts when integrating Huawei push channel, follow these steps to integrate Huawei Vendor push service:

  1. Cancel the project pair "com.tencent.tpns:huawei:[VERSION]-release" The dependency of this single dependency package.
  2. When integrating Huawei's official SDK with reference to the official documentation of Huawei developer platform, check the push module at the same time to add push function to Huawei SDK.
  3. In the source code of the HMSAgent module, the utility class com.huawei.android.hms.agent.common.StrUtils Make the following changes to resolve the failure of Huawei Vendor token registration caused by an exception within Huawei SDK.
    Before modification:
package com.huawei.android.hms.agent.common;
public final class StrUtils {
    public static String objDesc(Object object) {
        return object == null ? "null" : (object.getClass().getName()+'@'+ Integer.toHexString(object.hashCode()));
    }
}

After modification:

package com.huawei.android.hms.agent.common;
public final class StrUtils {
    public static String objDesc(Object object) {
        String s = "";
        try {
            s = Integer.toHexString(object.hashCode());
        } catch (Throwable e) {
        }
        return object == null ? "null" : (object.getClass().getName()+'@'+ s);
    }
}
  1. Add a new broadcast receiver class HWPushMessageReceiver.java, that inherits from Huawei's push callback broadcast PushReceiver and rewrite the interface onToken, as follows to store Huawei token locally for TPNS to call:
public class MyReceiver extends PushReceiver {
    @Override
    public void onToken(Context context, String arg1, Bundle arg2) {
        if(token != null && token.length() != 0) {
            SharedPreferences sp = context.getApplicationContext().getSharedPreferences("tpush.vip.shareprefs", Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = sp.edit();
            editor.putString("huawei_token", token);
            editor.commit();
        }
    }
}
  1. Add HWPushMessageReceiver configuration to AndroidManifest.xml as follows:
<receiver android:name="com.tencent.android.hwpush.HWPushMessageReceiver" >
  <intent-filter>
       <!-- Required; used to receive TOKEN -->
       <action android:name="com.huawei.android.push.intent.REGISTRATION" />
       <!-- Required; used to receive message -->
       <action android:name="com.huawei.android.push.intent.RECEIVE" />
       <!-- Optional; used to trigger the onEvent callback after the notification bar or a button in the notification bar is tapped -->
       <action android:name="com.huawei.android.push.intent.CLICK" />
       <!-- Optional; used to check whether the PUSH channel is connected; not needed if there is no need to view -->
       <action android:name="com.huawei.intent.action.PUSH_STATE" />
  </intent-filter>
</receiver>

How to solve the exception when using the console for quick integration?

  1. If an exception occurs in the integration, set the tpns-configs.json In the file "debug" Field set to true , run the command:
./gradlew --rerun-tasks :app:processReleaseManifest 

And through "TpnsPlugin" Keyword for analysis.
2. Click sync projects.

  1. Check the External Libraries of the project to see if there are any dependencies.