얼마전까지만 해도 잘 사용해왔는데 웹단에서는 에러 없이 잘 보내는 걸 확인했는데
앱단에서 메시지 받았을 때 GCMIntentService 클래스를 호출하지 않습니다.
public GcmIntentService()
{
super("GcmIntentService");
}
@Override
protected void onHandleIntent(Intent intent)
{
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))
{
String msg = intent.getStringExtra("msg");
// Post notification of received message.
// sendNotification("Received: " + extras.toString());
sendNotification(intent);
Log.i("GcmIntentService", "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(Intent intents)
{
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
String title = intents.getStringExtra("title");
String msg = intents.getStringExtra("msg");
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("title", title);
intent.putExtra("msg", msg);
intent.putExtra("eventcode", intents.getStringExtra("eventcode"));
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setStyle(
new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg).setAutoCancel(true).setVibrate(new long[] { 0, 500 });
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
현재 소스인데 메시지 받았을 때 sendNotification(intent);를 호출해야 되는데
디버깅 해봐도 전혀 타질 않네요
문제가 있나요?
아니면 혹시 GCM 변경된 정책같은게 있나요?
새로 등록해야된다던가..