RedShirt
RedShirt

Reputation: 864

Android: Unable to receive GCM Messages/ Listener not being called

I am missing something and I am not sure what considering I followed the guide ie: https://developers.google.com/cloud-messaging/android/client

as well as checked my code against: https://github.com/googlesamples/google-services/tree/master/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart

My server side code is correct will successfully send out a GCM message but my android client does not receive anything.

I am thinking the issue lies somewhere in the manifest:

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mypackage.here"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="21" />

    <permission
        android:name="com.mypackage.here.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.mypackage.here.permission.C2D_MESSAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- C2DM service Receive -->
        <!-- [START gcm_receiver] -->
        <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.mypackage.here" />
            </intent-filter>
        </receiver>
        <!-- [END gcm_receiver] -->


        <!-- [START gcm_listener] -->
        <service
            android:name=".EPAOAGcmListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <!-- [END gcm_listener] -->
        <!-- [START instanceId_listener] -->
        <service
            android:name=".EPAOAInstanceIDListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>
        <!-- [END instanceId_listener] -->
        <service
            android:name=".EPAOAGcmRegisterIntentService"
            android:exported="false" >
        </service>
        <!-- C2DM service Receive End -->

    </application>

</manifest>

I will note that I am registering and receiving the device token perfectly fine. I just cannot receive messages (notifications). If no immediate thoughts come to mind while looking through the manifest, it would be appreciated if a suggestion were to be made about the next place I should look.

Upvotes: 0

Views: 266

Answers (2)

Oussema Smaoui
Oussema Smaoui

Reputation: 97

You should write your package's name which is com.mutalminds.epaoa instead of com.mypackage.here .

Upvotes: -1

OBX
OBX

Reputation: 6114

Simple answer is: not to worry! For the first time it is obvious to take some time! It is attributed to the synchronization that happens in the Google Servers.

Furthermore, if its Notifications it can take up to 15-28 min delay, because: The GCM framework part on the client phone use a TCP connection on the port 5228. This connection its used for push notifications, but as every tcp connection it can go on timeout with some routers/carriers that apply strict policies to kill inactive tcp connections (tcp idle timeout).

Most wifi routers kills inactive connections after 5 minutes for example, like mine.

The GCM framework use a keep-alive mechanism to send an heartbeat network packet every 15 minutes on wifi and every 28 minutes on 3G.

Upvotes: 2

Related Questions