给特定 wordpress 用户的 FCM 通知

2023-07-29移动开发问题
2

本文介绍了给特定 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 为每个用户提供自己的主题.让应用订阅该主题,并在您需要定位用户时向用户的主题发送消息.

另见:

  • 如何使用 Firebase 消息传递一对一消息
  • 使用 firebase 向自定义用户发送消息
  • 按用户向用户发送 Firebase 云消息传递通知属性
  • 如何向用户发送数据消息来自 Rest API 的分段

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

The End

相关推荐

如何在 COCOS2d Android 中使用 CClistview?
How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)...
2024-08-12 移动开发问题
5

在 iphone 中解析推送通知
Parse push notification in iphone(在 iphone 中解析推送通知)...
2024-08-12 移动开发问题
10

cocos2d-android:如何显示分数
cocos2d-android: how to display score(cocos2d-android:如何显示分数)...
2024-08-11 移动开发问题
7

Sqlite 数据库未从资产文件夹 Android 复制
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)...
2024-04-15 移动开发问题
8

SQLite 数据库副本在由设备而不是模拟器生成时出现损坏
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)...
2024-04-15 移动开发问题
4

安卓文件拷贝
Android file copy(安卓文件拷贝)...
2024-04-15 移动开发问题
6