给特定 wordpress 用户的 FCM 通知 [英] FCM Notification to specific wordpress user

查看:12
本文介绍了给特定 wordpress 用户的 FCM 通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于 wordpress 博客的 android 应用程序,用户可以在其中发布自己的文章,我使用 WP REST API 来获取帖子、评论和用户......

i am developping an android application based on a wordpress blog where users can post their own articles, i work with WP REST API to get posts , comments and users ...

我想在他的文章有新评论时自动向用户发送通知,我已经正确安装了 FCM 并测试了简单的通知形式,但我需要:

I would like to send a notification automatically to the user when his article got a new comment , i have installed FCM correctly and tested the simple forme of notifications but i need to :

  • 发送新评论时触发 FCM 通知(或只需单击按钮)
  • 指定接收者,以便使用正确的电子邮件/用户名将通知发送给登录用户

我想到了

  • 为每个这样记录的用户设置用户属性:

mFirebaseAnalytics.setUserProperty("user_name_for_notification", "the_username");

  • 为所有设备发送通知,然后在 onMessageReceived
  • 中处理它

但我不认为这些是好主意

but i don't think those are good ideas

所以,任何想法从哪里开始

So , any ideas where to start

谢谢

推荐答案

FCM 可以通过三种不同的定位方法发送通知:

FCM can send notifications with three different targeting methods:

  1. 到特定的 FCM 令牌/实例 ID 令牌,用于标识特定设备上特定应用程序的安装.
  2. 到一组此类设备/实例 ID.
  3. 到 FCM 客户可以订阅的特定主题.

Firebase Cloud Messaging 没有用户的概念,因此不能直接针对用户.如果您想定位用户,您必须将他们映射到上面列出的定位方法之一.

Firebase Cloud Messaging does not have the concept of a user, therefor it cannot target users directly. If you want to target users, you will have to map them to one of the targeting methods outline above.

我所知道的最常见的方式:

The most common ways that I know of:

  1. 将用户的令牌存储在其 UID 下的数据库中,然后在需要定位用户时发送到用户的令牌.
  2. 根据用户的 UID 为每个用户提供自己的主题.让应用订阅该主题,并在您需要定位用户时向用户的主题发送消息.

另见:

这篇关于给特定 wordpress 用户的 FCM 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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