如何使用切换按钮禁用FCM推送通知? [英] How to disable FCM push notification using toggle button?

查看:128
本文介绍了如何使用切换按钮禁用FCM推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xamarin和firebase开发移动应用程序推送通知. 我想在应用程序上放置一个切换按钮以关闭警报. 我尝试了很多,但解决不了.

I'm develop mobile app push notification using xamarin and firebase. I want to put a toggle button on my application to turn off the alarm. I tried a lot but i could not solve it.

我想说很多话,但是我不会说英语,而且我正在使用Google翻译. 请帮助我.

There are many words I want to say, but I can not speak English and I am using Google Translator. Please help me.

  1. 我尝试使用名为"allowPushNotification"的fcm主题禁用推送通知. 打开切换按钮时,关闭切换按钮时,已订阅主题和未订阅主题. 但是,当我使用令牌"发送推送通知时,无论用户的"allowPushNotification"选项如何,都会发送推送. 是否可以执行以下操作?
  1. I tried disable push notification using fcm topic named 'allowPushNotification'. When turn on toggle button, subscribed topic, and unsubscribed topic when turn off toggle button. But when i send to push notification using 'TOKEN', A push is sent regardless of the user's 'allowPushNotification' options. Is it possible to do the following?

{ 至":"TOKENTOKENTOKENTOKEN", 和 "condition":主题中的'allowPushNotification' }

{ "to":"TOKENTOKENTOKENTOKEN", AND "condition":"'allowPushNotification' in topics" }

  1. 我试图控制"OnPushReceived"事件的显示推送警报,但失败. 在此事件中,我检查了允许推送选项,并使用了明确的Notification方法.但收到->清除->显示推送....

  1. I tried to control display push alarm on 'OnPushReceived' event, but it failed. On this event, i checked allow push option, and use clear Notification method. but received -> clear -> display push....

我想到了用户的允许推送通知选项数据到我的数据库,并使用db查询过滤了用户目标. 但是这样,每次用户按下切换按钮时,都会有很多不必要的数据库访问.

I thought about user's allow push notification option data to my database and filtered the user target using db query. but this way, There is a lot of unnecessary database access when every time the user presses the toggle button.

如果解决了,我想在特定时间拒绝推送通知. 帮帮我...

If this resolves, I want to reject the push notification at a certain time. help me...

推荐答案

如果通过令牌将消息发送到设备,则该消息将不会遵循您的主题设置.如果要阻止此类通知,则需要进入系统设置.您可以参考此链接.

If you send a message to a device by token, it will not follow your topic setting. If you want to block this kind of notification, you need to go to system setting. You could refer to this link.

当应用程序在后台运行时,不会触发OnMessageReceived()方法.我认为您最好不要通过令牌发送消息.尽可能使用主题消息.

When the app is in the background, the OnMessageReceived() method will not be fired. I think you'd better not to send the message by Token. Using Topic messaging if it possible.

这篇关于如何使用切换按钮禁用FCM推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆