繁体   English   中英

PHP Firebase通知显示在托盘中,但没有弹出

[英]PHP Firebase notification shows in tray but not popping up

我正在使用php将使用Firebase的推送通知发送到使用unity的Android应用程序构建。 应用正在接收通知并将其显示在托盘中,但没有像应用程序或其他应用程序那样将其显示为弹出通知。

我的PHP代码是:

function send_notification ($tokens, $message){
    $url = 'https://fcm.googleapis.com/fcm/send';
    $notification= array('title' => 'Winner!!','body' => $message);
    $data= array('custom_notification' => $custom_notification );
    $fields = array(
            'registration_ids' => $tokens,
            'notification' => $notification,
        );

    $headers = array(
        'Authorization:key = AAAA5C-Y_Ew:APA91bFD1g98n19DZD8FkaEYiME4tDsniePTKU1sGww1EAD7dtSKP6FEqlRGcTpB_MCD_7UM7ToWis1VnZO-dtDXMLFSZtaSIDAQ0fACbJ_SOFjWd93klckboahy3eZr93Z9M02LfP_s',
        'Content-Type: application/json'
        );
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_POST, true);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);  
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
   $result = curl_exec($ch);           
   if ($result === FALSE) {
       die('Curl failed: ' . curl_error($ch));
   }
   curl_close($ch);
   return $result;
}

它还显示灰度图标而不是彩色图标。 我想将通知显示为弹出窗口。 反正有使用FCM这样做吗?

而不是'notification' => $notification仅在发送Android 'notification' => $notification仅使用data键。

iOS仅需要'notification' => $notification

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM