[英]How can I send push notification from PHP website to iOS and Android?
如何从 PHP 网站向 iOS 设备和 Android 设备发送推送通知?
有没有相关的教程?
您可以使用多种预制服务来推送通知,例如 Firebase Messaging、One Signal 等。有关 Firebase Cloud Messaging 与 PHP 的集成,请访问此链接。 设置后,只需使用用户令牌发送此 POST 请求
POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1
Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...PbJ_uNasm
{
"message": {
"token" : <token of destination app>,
"notification": {
"title": "FCM Message",
"body": "This is a message from FCM"
},
"webpush": {
"headers": {
"Urgency": "high"
},
"notification": {
"body": "This is a message from FCM to web",
"requireInteraction": "true",
"badge": "/badge-icon.png"
}
}
}
}
或使用主题发送推送通知
https://fcm.googleapis.com//v1/projects/<YOUR-PROJECT-ID>/messages:send
Content-Type: application/json
Authorization: bearer <YOUR-ACCESS-TOKEN>
{
"message": {
"topic": "matchday"
"notification": {
"title": "Background Message Title",
"body": "Background message body"
},
"webpush": {
"fcm_options": {
"link": "https://dummypage.com"
}
}
}
}
对于一个信号,请访问此链接了解更多信息。 此外,如果您不想要预制服务,也可以使用网络套接字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.