【发布时间】:2017-07-24 05:03:10
【问题描述】:
我想从 php.ini 发送一个带有 "room" 字符串的通知。这是我的代码:
define( 'API_ACCESS_KEY', '--------------------------' );
#prep the bundle
$msg = array (
'body' => $_GET['isi'],
'title' => $nama." mengirim pesan",
'icon' => 'myicon',/*Default Icon*/
'sound' => 'mySound',/*Default sound*/
'room' => $room //This is String I want to send
);
$fields = array (
'to' => $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 );
我想在这里收到一串“房间”:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMessagingService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
sendNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
}
}
我怎样才能得到“房间”的字符串? 谢谢..
【问题讨论】:
标签: php android firebase push-notification firebase-cloud-messaging