Permalink
Browse files

receive message

  • Loading branch information...
1 parent f745eda commit 9bde4b69842fb696472c8ec129a55cb4e9bc9158 @susemi99 committed Jan 26, 2016
@@ -3,6 +3,9 @@
package="kr.susemi99.gcm"
xmlns:android="http://schemas.android.com/apk/res/android">
+ <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
+
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@@ -19,9 +22,29 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
+
<service
android:name=".services.RegistrationIntentService"
android:exported="false"/>
+
+ <receiver
+ android:name="com.google.android.gms.gcm.GcmReceiver"
+ android:exported="true"
+ android:permission="com.google.android.c2dm.permission.SEND">
+ <intent-filter>
+ <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
+
+ <category android:name="kr.susemi99.gcm"/>
+ </intent-filter>
+ </receiver>
+
+ <service
+ android:name=".services.GCMMessageListenerService"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
+ </intent-filter>
+ </service>
</application>
</manifest>
@@ -0,0 +1,22 @@
+package kr.susemi99.gcm.services;
+
+import android.os.Bundle;
+import android.util.Log;
+
+import com.google.android.gms.gcm.GcmListenerService;
+
+public class GCMMessageListenerService extends GcmListenerService
+{
+ @Override
+ public void onMessageReceived(String from, Bundle data)
+ {
+ super.onMessageReceived(from, data);
+ Log.i("GCMMessageListenerService | onMessageReceived", "from : " + from);
+
+ for (String key : data.keySet())
+ {
+ Object value = data.get(key);
+ Log.i("GCMMessageListenerService | onMessageReceived", String.format("%s : %s (%s)", key, value.toString(), value.getClass().getName()));
+ }
+ }
+}

0 comments on commit 9bde4b6

Please sign in to comment.