可以禁用当前应用的推送通知吗? 我正在使用Google GCM通知中的示例。在应用程序中,我希望当我退出时 - 禁用推送通知。只能在推送通知发送给我的服务器上禁用代码或其需要禁用
注意,彼得。
[UPD] 谢谢Oleg,我也在MessageReceiver中找到了一种方法
@Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
if(notificationsDisabled) {
// do what u want when notifications variable disabled (without server etc)
}else{
// if enabled , show notifications message in status bar or something else
}
}
当需要从服务器更新某些内容但没有推送通知时,这是一个好方法
答案 0 :(得分:2)
您可以在starup手动注册GcmBroadcastReceiver
,在退出时注销