Android推送通知中的空白通知图标


Blank Notification Icon in Android Push Notification

我目前正在使用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.

问题已解决:

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

  2. 设置android:targetSdkVersion="19"(<20棒棒糖5.0)