0

I am currently using PHP code to send Android GCM Push Notification

    $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 );

I always receive a blank (white square) in notification. I didn't specify any icon for notification in the Android app - just the default app icon set.

I can send an image in data, but the notification icon is still blank:

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

I have tried to set an URL for 'icon', 'smallIcon', 'largeIcon', but not successful. I am using Apache Cordova and com.adobe.phonegap.push.PushPlugin.

Neo
  • 63
  • 10

1 Answers1

2

PROBLEM SOLVED:

  1. First set the notification icons to the recommended sizes: 24x24(mdpi), 36x36(hdpi),48x48(xhdpi),72x72(xxhdpi)

  2. Set android:targetSdkVersion="19" (<20 Lollipop 5.0)

Neo
  • 63
  • 10