【问题标题】:Backendless issue, how to prevent push notification from showing后端问题,如何防止推送通知显示
【发布时间】:2016-12-15 13:56:51
【问题描述】:

如果不使用注销来推送通知,我希望在某些情况下阻止通知显示在 android 通知中心。

后端有一大段代码执行以下操作:

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

实施 BackendlessPushService 类中的方法包含以下逻辑 在 Android 通知中心显示推送通知。到 取消推送通知的默认处理,确保您的 代码返回 false。

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

【问题讨论】:

    标签: java android push-notification backendless


    【解决方案1】:

    请关注 GitHub 上的文档:https://github.com/Backendless/Android-SDK/blob/master/docs/push.md

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

    1. 覆盖BackendlessPushService并从onMessage()方法返回false
    2. 覆盖 BackendlessBroadcastReceiver 并从 getServiceClass() 方法返回您的实现类
    3. AndroidManifest.xml 中声明您的首要接收器

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多