0

I'm trying to setup Google Cloud Messaging between an Android app (Android Studio) and a server. I'm following the directions here: Set up a GCM Client App on Android. The code below is what I've added to my manifest file (as instructed).

<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="com.example.gcm" />
    </intent-filter>
</receiver>
<service
    android:name="com.example.MyGcmListenerService"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</service>
<service
    android:name="com.example.MyInstanceIDListenerService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID"/>
    </intent-filter>
</service>

This is probably a simple question, but I cannot figure out what com.example.MyGcmListenerService and com.example.MyInstanceIDListenerService should be. Android Studio says these symbols are not found. I have not found any help online or on the same instructions page as to what these values should be.

Do these values refer to classes I need to create? Do they refer to something local or remote? I have installed the required SDK components and Cloud Messaging tools (the com.google.android.gms.gcm.GcmReceiver does get resolved).

Sorry if this is obvious. I am new to Android Studio.

thatWiseGuy
  • 384
  • 2
  • 3
  • 18
  • Have you set `compile "com.google.android.gms:play-services:8.3.0"` in your build.gradle file yet? – BNK Dec 05 '15 at 01:17
  • Yes, I've included `compile "com.google.android.gms:play-services-gcm:8.3.0"`, which imports just the GCM components. I assumed `MyGcmListenerService` is just a placeholder for something since it starts with `My`. Is this how I should leave it? If not, what should go here? – thatWiseGuy Dec 05 '15 at 01:54
  • I suggest you read my answer at http://stackoverflow.com/questions/32299997/how-to-implement-a-gcm-hello-world-for-android-using-android-studio, hope it helps! – BNK Dec 05 '15 at 01:58
  • You can see that your `com.example.MyGcmListenerService` is equivalent to my `.GcmService` in my sample – BNK Dec 05 '15 at 02:05
  • Yes, I'm looking at that now, thanks. I'm going to create another class then. – thatWiseGuy Dec 05 '15 at 02:16
  • One question @BNK, did you not need to create a service to handle the registration token, as here? [See here](https://developers.google.com/cloud-messaging/android/client#sample-register) This seems to say this is required in order for the client to receive messages. – thatWiseGuy Dec 05 '15 at 03:10
  • The registration token got at client app, you should send it to the server app so that server app can send messages to client app. You can read my answer at http://stackoverflow.com/questions/32322631/adding-google-cloud-messagin-gcm-for-android-registration-process – BNK Dec 05 '15 at 03:13
  • In my 1st link, you can see in server-app `final String CLIENT_REG_ID = "..."; //An ID issued by the GCM connection servers to the client app that allows it to receive messages` that is the registration token of client app – BNK Dec 05 '15 at 03:16
  • You can refer to my 2 server/client sample projects at https://github.com/ngocchung/GCMAndroid and https://github.com/ngocchung/GCMServer – BNK Dec 05 '15 at 04:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97087/discussion-between-thatwiseguy-and-bnk). – thatWiseGuy Dec 05 '15 at 21:13

0 Answers0