Backendless问题,如何防止推送通知显示

Backendless issue, how to prevent push notification from showing

在不使用注销推送通知的情况下,我想在某些情况下阻止通知显示在 android 通知中心。

backendless 中有一段代码执行以下操作:

public class MyPushService extends BackendlessPushService
{

    @Override
    public boolean onMessage( Context context, Intent intent )
    {
        if (...) do something that shows the notif
        else do something to hide the notif (not showing the notif at all)
    }

    @Override
    public void onError( Context context, String message )
    {
        System.out.println(message);
    }
}

来自以下文档:https://backendless.com/documentation/messaging/android/messaging_push_notification_setup_androi.html

The implementation of the method in the BackendlessPushService class contains the logic of displaying push notifications in the Android Notification Center. To cancel the default handling of the push notification, make sure your code returns false.

即使我 return 为 false,我仍然会看到通知,我该如何防止这种行为?

请按照 GitHub 上的文档进行操作:https://github.com/Backendless/Android-SDK/blob/master/docs/push.md

为了实现不显示推送通知,您需要执行以下操作:

  1. onMessage() 方法覆盖 BackendlessPushService 和 return false
  2. getServiceClass() 方法
  3. 覆盖 BackendlessBroadcastReceiver 和 return 你的实现 class
  4. AndroidManifest.xml
  5. 中声明您的重写接收器

上面提供的link用代码详细描述了所有这些步骤。