无后台的问题,如何防止推送通知显示
问题描述:
如果没有使用注销推送通知,我想,在某些情况下,以防止通知显示在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);
}
}
在BackendlessPushService类的 方法的实现包含逻辑 在Android通知中心显示推送通知。若要 取消推送通知的默认处理,请确保您的 代码返回false。
即使当我返回false,我仍然看到通知,我该如何防止该行为?
答
请按照GitHub上的文档:https://github.com/Backendless/Android-SDK/blob/master/docs/push.md
为了达到不显示推送通知,你需要做到以下几点:
- 覆盖
BackendlessPushService
和onMessage()
方法 - 覆盖返回
false
BackendlessBroadcastReceiver
并从getServiceClass()
方法返回您的实施类 - 声明你的ove rrosing receiver in
AndroidManifest.xml
所有这些步骤都在上面提供的链接中用代码详细描述。