FCM推送通知问题:-不显示通知图像,如Samsung mobile

时间:2019-02-25 07:30:27

标签: php opencart2.3

> <?php
> function send_push_fcm_notification($registration_ids,
> $message){ 
define('API_ACCESS_KEY', $this->config( 'access_key'));
> $actionData = array( ); 
> if ( !empty( $message[ 'product_id' ] ) ) {
> $actionData = array( 'id' => $message[ 'product_id' ], 'actionpage' =>
> 'product'  ); } //!empty( $message[ 'product_id' ] ) else if ( !empty(
> $message[ 'category_id' ] ) ) { $actionData = array( 'id' => $message[
> 'category_id' ], 'actionpage' => 'category'  ); } //!empty( $message[
> 'category_id' ] ) else if ( $message[ 'category_list' ] == 'Deals' ) {
> $actionData = array( 'actionpage' => 'deals'  ); } //$message[
> 'category_list' ] == 'Deals' $msg = array( 'message' => $message[
> 'body' ], 'title' => $message[ 'header' ], 'subtitle' => $message[
> 'body' ], 'tickerText' => $message[ 'body' ], 'vibrate' => 1, 'sound'
> => 1, 'largeIcon' => 'large_icon', 'smallIcon' => 'small_icon', 'style' => '', 'priority' => 1, 'image' => 'icon.png', 'click_action'
> => 'FCM_PLUGIN_ACTIVITY', 'forceShow' => 'true', 'content-available' => true, 'extadata' => $actionData  ); if ( !empty( $message[ 'banner_image' ] ) ) { $msg[ 'picture' ] = $this->request->post[
> 'banner_image' ]; $msg[ 'style' ]   = 'picture'; } //!empty( $message[
> 'banner_image' ] ) $registration_ids        = ''; $registration_ids[
> '0' ] = $this->config( 'reg_id' ); $fields                  = array(
> 'registration_ids' => $registration_ids, 'data' => $msg  ); $headers  
> = array( 'Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json'  ); $ch                      = curl_init();
> curl_setopt( $ch, CURLOPT_URL,
> 'https://android.googleapis.com/gcm/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 ); if ( $result ===
> FALSE ) { die( 'Curl failed: ' . curl_error( $ch ) ); } //$result ===
> FALSE curl_close( $ch ); return $result; }

> ?>

</pre>

0 个答案:

没有答案