Note that there are some explanatory texts on larger screens.

plurals
  1. POConfusions about new GoogleCloudMessaging API (not the old one)
    primarykey
    data
    text
    <p>i have followed the tutorial for GCM available at the official site:</p> <pre><code>http://developer.android.com/google/gcm/gs.html </code></pre> <p>and i have successfully implemented it on my app.. but as i am new on android i have few confusions about GCM i would really appriciate if someone could clear these points.</p> <ul> <li><p>i wrote a PHP script(found from google) and hardcoded my regisration ID (just for testing) when i run the script i recieve a notification on my device.. but i dont wanna receive a notification rather i want to silently recieve the data and handle it on my device. is it possible?? here is the PHP code:</p> <pre><code>$regID=$_REQUEST['regID']; $registatoin_ids=array($regID); $msg=array("message"=&gt;'HI Wasif'); $url='https://android.googleapis.com/gcm/send'; $fields=array ( 'registration_ids'=&gt;$registatoin_ids, 'data'=&gt;$msg ); $headers=array ( 'Authorization: key=MY-REG-KEY', '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_VERIFYPEER,false); curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode($fields)); $result=curl_exec($ch); curl_close($ch); echo $result; </code></pre></li> <li><p>Second point is i want to customize the notification i receive on my device i receive a notification like this...(see picture below) but i want to replace the heading text "GCM Notification" with my app's name and the message should me displayed properly(not like the key,value text) and also change the image of notification... can anybody plz provide a tutorial how to do it in new GoogleCloudMessaging API?? (please dont provide old methods if it is not same for new GoogleCouldMessaging API) <img src="https://i.stack.imgur.com/ofeps.png" alt="enter image description here"></p> <p>BROADCAST RECEIVER CODE: public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); } } </code></pre></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload