java后台问题,如何防止推送通知显示
在不使用unregister来推送通知的情况下,我希望在某些情况下,阻止通知显示在安卓通知中心中
后台有一段代码可以执行以下操作:
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/安卓/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.
即使我返回false,我仍然会看到通知,如何防止这种行为
# 1 楼答案
请遵循GitHub上的文档:https://github.com/Backendless/Android-SDK/blob/master/docs/push.md
要完成不显示推送通知,需要执行以下操作:
BackendlessPushService
并从onMessage()
方法返回false
BackendlessBroadcastReceiver
并从getServiceClass()
方法返回实现类AndroidManifest.xml
中声明覆盖接收器所有这些步骤都通过上面提供的链接用代码进行了详细描述