[英]How to send iOS push notifications with PHP?
I am trying to send push notifications with PHP to an iOS device. 我正在尝试使用PHP将推送通知发送到iOS设备。 I have the device token, but I don't know how to set up the server itself.
我有设备令牌,但是我不知道如何设置服务器本身。 I have been able to register the device with
UserNotifications
in the AppDelegate.swift
file. 我已经能够在
AppDelegate.swift
文件中使用UserNotifications
注册该设备。 I am using Xcode 10 and Swift 4. 我正在使用Xcode 10和Swift 4。
There are two options actually 实际上有两个选择
1. Send to APNS directly: There is comprehensive guide to send Push payload to APNS here . 1.发送到APNS直接:有全面的指导,推动有效载荷发送到APNS 这里 。
2. Rely on a 3rd party: Many 3rd party services provide a free solution. 2.依靠第三方:许多第三方服务提供免费的解决方案。 Among them, Firebase is pretty popular, backed up by Google, and push to iOS/Android/Web platform all in one.
其中,Firebase非常受欢迎,由Google支持,并一站式推送到iOS / Android / Web平台。 This guide will walk you through how to configure your iOS client to integrate Firebase/Messaging SDK.
本指南将引导您逐步配置iOS客户端以集成Firebase / Messaging SDK。 To send push payload to Firebase, use this guide , which will allow you through simple HTTP call with necessary payload to send the push.
要将推送有效负载发送到Firebase,请使用本指南 , 该指南将允许您通过简单的HTTP调用以及必要的有效负载来发送推送。
NB: Among these two options, I would suggest to use Firebase to send your push. 注意:在这两个选项中,我建议使用Firebase发送您的推送。 Your PHP end's complexity will reduce to just maintain firebase instance token, and the payload creation is much more simplified by using the firebase for different platforms.
您的PHP端的复杂性将降低,仅维护Firebase实例令牌,而通过将Firebase用于不同的平台,有效负载的创建将大大简化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.