【发布时间】:2017-07-12 01:40:09
【问题描述】:
我正在使用以下脚本向特定用户发送通知:
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'My_API_KEY' );
$registrationIds = array( TOKENS );
// prep the bundle
$msg = array
(
'body' => "abc",
'title' => "Hello from Api",
'vibrate' => 1,
'sound' => 1,
);
$fields = array
(
'registration_ids' => $registrationIds,
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>
脚本运行良好,但我如何向所有安装了我的应用程序的用户发送通知。我在我的应用程序(警报)中创建了一个主题,我可以通过 firebase 控制台向所有用户发送通知。谁能指导我更新上面的主题脚本。
【问题讨论】:
-
能否提供IDE中推送通知部分的代码? !I have coded the php script part 我不知道如何向 Firebase 服务器发送请求。请分享 IDE 中处理推送通知的代码!.
标签: php android firebase firebase-cloud-messaging