El dispositivo no recibe mensaje de NUEVO mensaje de nube de Google (NUEVO GCM)

por favor ayúdame he estado navegando sobre este tema, y ​​todavía apilar en este nuevo GCM

mi último proyecto usando GCM Push según este enlace

ht **: //www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

pero ahora, el último GCM (C2DM) está obsoleto, por lo que no utilizamos más GCMRegistrar

aquí, eche un vistazo a este h ** p: //developer.android.com/google/gcm/c2dm.html hay una declaración "Android Cloud a Device Messaging (C2DM) está obsoleto. El servicio C2DM seguirá siendo mantenido en el corto plazo, pero C2DM no aceptará nuevos usuarios y no concederá nuevas cuotas "

Yo uso este enlace para aprender el concepto

y para el ejemplo que uso: https://code.google.com/p/gcm/source/browse/#git

pienso, he seguido todos los pasos requeridos

he hecho referencia a mi proyecto a google play service lib

También he cambiado mi ID de remitente a mi número de proyecto de google

También he recibido RegID de GCM

pero el problema es, cada vez que haga clic en el botón de enviar

nunca me muestra nada

del ejemplo de la documentación de google, dice que debería ECHO volver a mi dispositivo, pero nunca lo hace

he comprobado en la documentación el concepto dice que gcmbroadcastreceiver recibirá cualquier Mensaje GCM empujado a mi dispositivo,

así que traté de registrar dentro de la "OnReceive" en ese radiodifusor, pero nunca mostrar nada

También intenté implementar HTTP GCM Server utilizando esta documentación http://developer.android.com/google/gcm/http.html

obtengo la respuesta de este modo {"multicast_id": 6256370624066466203, "success": 1, "failure": 0, "canonical_ids": 0, "results": [{"message_id": "0: 1378114688323559% eab45603f9fd7ecd"}] }

pero mi registro nunca muestra nada

aquí está mi receptor de difusión

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.v("HAHA BANGET","masuk ke broadcastReceiver"); // 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); } } 

y aquí está mi intentservice

 public class GcmIntentService extends IntentService { public static final int NOTIFICATION_ID = 1; private NotificationManager mNotificationManager; NotificationCompat.Builder builder; public GcmIntentService() { super("7134XXXXX"); } public static final String TAG = "HAHA"; @Override protected void onHandleIntent(Intent intent) { Log.v(TAG,"MASUK INTENT NIH"); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification("Received: " + extras.toString()); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } // Put the message into a notification and post it. // This is just one simple example of what you might choose to do with // a GCM message. private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, PushBaruLagi.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.common_signin_btn_icon_dark) .setContentTitle("GCM Notification") .setStyle(new NotificationCompat.BigTextStyle() .bigText(msg)) .setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } } 

y aquí está mi manifiesto

 <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <permission android:name="com.coba.pushgcmbaru.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.coba.pushgcmbaru.permission.C2D_MESSAGE" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <receiver android:name="com.coba.pushgcmbaru.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.coba.pushgcmbaru" /> </intent-filter> </receiver> <service android:name="com.coba.pushgcmbaru.GcmIntentService" /> <activity android:name="com.coba.pushgcmbaru.PushBaruLagi" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> 

estoy usando 2.2 FROYO

y he actualizado mis servicios de Google Play a los más nuevos

así que chicos, si alguien podría por favor me ayude, muchas gracias 🙂

Prueba de esta manera

UPDATE: Nueva implementación de API de GCM

1) crear la clase GcmIntentService.java

 public class GcmIntentService extends IntentService { public GcmIntentService() { super("your project id here"); } @Override protected void onHandleIntent(Intent intent) { // handle message here } } 

2) crear la clase GcmBroadcastReceiver.java

 public class GcmBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); context.startService((intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); } } 

3) Mainfest.xml

pemissions para GCM

 <permission android:name="your.package.name.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="your.package.name.permission.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <receiver android:name="your.package.name.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android:name="com.google.android.c2dm.intent.GCM_RECEIVED_ACTION" /> <category android:name="your.package.name" /> </intent-filter> </receiver> <service android:name="your.package.name.GcmIntentService" android:enabled="true" /> 

———————- OLD API ————————– ———————-

 public GcmIntentService() { super("72544799xxx"); //Pass GCM project id here } <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android:name="com.google.android.c2dm.intent.GCM_RECEIVED_ACTION" /> <category android:name="com.coba.pushgcmbaru" /> </intent-filter> </receiver> <service android:name="com.coba.pushgcmbaru.GCMIntentService" android:enabled="true" /> 

Cree la clase GCMReceiver y reemplácela con su GcmBroadcastReceiver

 import com.google.android.gcm.GCMBroadcastReceiver; /** * This Class Contains All Method Related To GCMReceiver. * * @author * */ public class GCMReceiver extends GCMBroadcastReceiver { @Override protected String getGCMIntentServiceClassName(Context context) { return GCMIntentService.class.getName(); } } 
 // registration int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (status == ConnectionResult.SUCCESS) { final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); new Thread(new Runnable() { @Override public void run() { try { gcm.register( Constants.GCM_SENDER_ID ); // old style google cloud messaging register process ---------------------- // Intent intent = new Intent( "com.google.android.c2dm.intent.REGISTER" ); // intent.putExtra("app",PendingIntent.getBroadcast(this,0,new Intent(),0)); // intent.putExtra("sender", Constants.GCM_SENDER_ID ); // startService( intent ); // ------------------------------------------------------------------------ } catch ( IOException e ) { } catch ( Exception ex) { } } }).start(); } else if (status != ConnectionResult.SUCCESS) { if (GooglePlayServicesUtil.isUserRecoverableError(status)) { Toast.makeText(this, getString(R.string.error_gcm_installplayservices), Toast.LENGTH_SHORT).show(); finish(); } else { Toast.makeText(this, getString(R.string.error_gcm_devicenotsupported), Toast.LENGTH_SHORT).show(); finish(); } } // class for all responses public class PushNotificationReceiver extends WakefulBroadcastReceiver implements IntentClientHubInterface { @Override public void onReceive(Context context, Intent intent) { if( intent != null && "com.google.android.c2dm.intent.REGISTRATION".equals(intent.getAction())) { String registrationId = intent.getStringExtra("registration_id"); String error = intent.getStringExtra("error"); if( error == null && context != null) { Utils.saveRegistrationID( context, registrationId ); } } else if ( intent != null && "com.google.android.c2dm.intent.RECEIVE".equals(intent.getAction()) ) { // handle notification } } } // permissions <?xml version="1.0" encoding="utf-8"?> <manifest ... <permission android:name="YOUR.PROJECT.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="YOUR.PROJECT.permission.C2D_MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permission.SEND" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <application ... <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <receiver android:name=".PushNotificationReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter android:priority="100"> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="YOUR.PROJECT" /> </intent-filter> </receiver> </application> </manifest> 
  • Subir una imagen a Google appengine utilizando Robospice con Retrofit
  • Cambiar la ubicación de una "Fábrica de procesador de anotaciones" para un proyecto de Android con App Engine
  • AppEngine RequestFactory o enfoque "Normal"?
  • ¿Cómo enviar un montón de coordenadas (x, y) a través de la red?
  • ¿Qué framework de Java REST para usar con App Engine y Android para los estudiantes?
  • Codificación de caracteres desordenada con Android + GAE Cloud Endpoints
  • Configurar el proxy TLS para las API de Google Cloud Endpoint
  • ¿Qué es el error Apache-HttpClient / UNAVAILABLE (Android, Google App Engine)?
  • Una manera fácil de autenticar las solicitudes de POST desde un cliente de Google Android a Google App Engine?
  • Interacción de Android con Google App Engine Blobstore Service
  • Puntos finales de Google Cloud y autenticación del usuario
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.