【发布时间】:2019-08-22 04:28:52
【问题描述】:
点击推送通知时如何在我的 Flutter 应用中打开特定页面。我创建了一个 php 脚本来推送 FCM 推送通知,但它只是打开应用程序首页.....我希望推送通知带有日期并在我的应用程序中打开日历页面并显示通知的详细信息。
<?php
if(isset($_GET['send_notification'])){
send_notification ();
}
function send_notification()
{
echo 'Hello';
define( 'API_ACCESS_KEY', 'Secret');
// $registrationIds = ;
#prep the bundle
$msg = array
(
'body' => 'App New Event Notification',
'title' => 'There is a new event added to the calendar',
);
$fields = array
(
'to' => $_REQUEST['token'],
'notification' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
#Send Reponse To FireBase Server
$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 );
echo $result;
curl_close( $ch );
}
?>
【问题讨论】:
标签: firebase push-notification flutter firebase-cloud-messaging