【问题标题】:Sending push notifications from one device to another in iOS在 iOS 中将推送通知从一台设备发送到另一台设备
【发布时间】:2017-08-27 18:25:12
【问题描述】:
我正在创建一个用户订购商品的 iOS 应用程序,当订单准备好时,供应商应该通过推送通知通知用户。
我的问题是,是否可以将推送通知从一台设备发送到另一台设备?
为此,我想使用 FCM。我读到他们允许两种消息。
- 下游,从服务器到设备的消息。
- 上游,从设备到服务器的消息。
上游消息会根据我的要求达到目的吗?如果是这样,我应该如何实施它们?
【问题讨论】:
标签:
ios
swift
push-notification
apple-push-notifications
【解决方案1】:
假设您使用的是Firebase,因此对于every registered 用户,有一个关联的device token id 保存到某个收藏夹中。 (注册流程)
假设您使用的是cloud functions(一个模糊的定义是运行到无服务器架构中的函数,并在被调用时执行)
所以您可以通过 HTTP 使用 Post Method 从您的应用中调用此函数
逻辑:
- extract that http request
- who is sending the message (uid, message)
- who needs to receive that message (someone)
- query that someone's device token id and save it to recipient_device_token_id
- construct to push notification payload (message)
- send push notification for recipients using its recipient_device_token_id
- end the http response
瞧,我相信还有其他方法可以做到这一点,但这会将所有逻辑从您的应用程序提取到云端。