【问题标题】:Blank Notification Icon in Android Push NotificationAndroid 推送通知中的空白通知图标
【发布时间】:2016-03-30 05:49:18
【问题描述】:

我目前正在使用 PHP 代码发送 Android GCM 推送通知

    $msg = array
    (
    'message' => $message,
    'title' => $title,
    'vibrate' => 1,
    'sound' => 'default'
    );
    $fields = array
    (
    'registration_ids' => $registrationIds,
    'data' => $msg
    );
    $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 );
    curl_close( $ch );

我总是收到一个空白(白色方块)的通知。我没有在 Android 应用中指定任何通知图标 - 只是默认的应用图标集。

我可以在数据中发送图像,但通知图标仍然是空白:

    'image' => 'http://www.example.com/image.png'

我尝试为“icon”、“smallIcon”、“largeIcon”设置 URL,但没有成功。我正在使用 Apache Cordova 和 com.adobe.phonegap.push.PushPlugin。

【问题讨论】:

标签: php push-notification google-cloud-messaging


【解决方案1】:

问题已解决:

  1. 首先将通知图标设置为推荐大小:24x24(mdpi)、36x36(hdpi)、48x48(xhdpi)、72x72(xxhdpi)

  2. 设置 android:targetSdkVersion="19" (

【讨论】:

  • 坚持使用旧的 targetVersion 更多的是一种解决方法,而不是解决方案。