[英]How to send push notification from user to user?
Trying to send push notification from user-to-user, UserA is bidding on the value for an item. 尝试从用户到用户发送推送通知,UserA对项目的价值出价。 Scenario, UserA updates a value in the app and clicks send, and at the same time UserB gets a notification of the updated value. 场景中,UserA更新了应用程序中的值,然后单击发送,同时UserB收到了更新值的通知。
If UserB approves of the message(value) {
UserA gets gets the notification of approval and proceeds to
final step of buying the item.
} else {
sends no and UserA is updated of the denial and he sends a new value for approval
}
A guide to accomplish the task would be greatly appreciated. 一个指南,以完成这项任务将不胜感激。
PS using firebase as backend 使用Firebase作为后端的PS
Since you are already using Firebase, you have it pretty easy. 由于您已经在使用Firebase,因此非常简单。
This tutorial explains everything you need to do this: 本教程说明了执行此操作所需的一切:
https://www.raywenderlich.com/140836/firebase-tutorial-real-time-chat-2 https://www.raywenderlich.com/140836/firebase-tutorial-real-time-chat-2
Essentially you need to do two things: 本质上,您需要做两件事:
Additionally, the firebase docs themselves explain this pretty well: https://firebase.google.com/docs/cloud-messaging/ios/topic-messaging 此外,firebase文档本身对此进行了很好的解释: https : //firebase.google.com/docs/cloud-messaging/ios/topic-messaging
You can use Firebase with the cloud messaging. 您可以将Firebase与云消息传递一起使用。 So UserA
creates the item. 因此, UserA
创建该项目。 UserB
is interested so he would subscribe to a topic about that item. UserB
感兴趣,因此他将订阅有关该项目的主题。
And every time there is an update, he would get a notification. 每次有更新时,他都会收到通知。 Check this https://firebase.google.com/docs/cloud-messaging/ios/topic-messaging 检查此https://firebase.google.com/docs/cloud-messaging/ios/topic-messaging
Sending Push Notifications is done with Apple Push Notification Service. 使用Apple Push Notification Service完成发送Push Notifications。 Apple provides a documentation on how to use APNs. Apple提供了有关如何使用APN的文档 。
The basic principal is illustrated in this picture. 基本原理如图所示。
Sending Messages from one device directly to another is not the way it works. 从一台设备直接向另一台设备发送消息不是它的工作方式。 You have to send a notification to the APNs in order to push them to another devices. 您必须向APN发送通知,以将其推送到其他设备。
Since you are using Firebase I would recommend using Firebase Cloud Messaging to send Push Notifications. 由于您使用的是Firebase,因此建议您使用Firebase Cloud Messaging发送推送通知。
If you just need real time updates in the app Firebase event listeners should work just fine. 如果您只需要在应用程序中进行实时更新, Firebase事件监听器就可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.