Daypi
Daypi

Reputation: 41

Cordova PushPlugin doesn't recieive notifications on Android emulator

I am using the latest Cordova version with the Push Plugin (https://github.com/phonegap-build/PushPlugin).

I am trying to use the example on the github page, on Android Emulator. I am running a nexus 4 VD, using Google API. The Google packages are installed, I have put the correct senderID in code.

My problem is : the application registers correctly and gets its regID, but doesn't receive any notifications.

To send the notifications i tried pushmeup (ruby gem) and this : http://gcm.codeplex.com.

Of course i put the right device token as well as the correct server API Key. Both server apps success and don't give me any errors.

Here is my android manifest :

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true"
    android:versionCode="1" android:versionName="0.0.1"
    android:windowSoftInputMode="adjustPan" package="io.cordova.hellocordova"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="18" />
    <supports-screens android:anyDensity="true"
        android:largeScreens="true" android:normalScreens="true"
        android:resizeable="true" android:smallScreens="true"
        android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <permission android:name="io.cordova.hellocordova.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="io.cordova.hellocordova.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <application android:allowBackup="true" android:icon="@drawable/icon"
        android:label="@string/app_name">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
            android:label="@string/app_name" android:name="HelloCordova"
            android:theme="@android:style/Theme.Black.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.plugin.gcm.PushHandlerActivity" />
        <service android:name="com.plugin.gcm.GCMIntentService" />
        <receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver"
            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" />
                <category android:name="io.cordova.hellocordova" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

Here is my config.xml :

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.helloCordova" version="2.0.0" xmlns="http://www.w3.org/ns/widgets">
    <name>Hello Cordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <feature name="App">
        <param name="android-package" value="org.apache.cordova.App" />
    </feature>
    <access origin="*" />
    <preference name="useBrowserHistory" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <plugin name="Device" value="org.apache.cordova.Device" />
    <plugin name="PushPlugin" value="com.plugin.gcm.PushPlugin" />
    <plugin></plugin>
    <feature name="Device">
        <param name="android-package" value="org.apache.cordova.device.Device" />
    </feature>
    <feature name="PushPlugin">
    <param name="android-package" value="com.plugin.gcm.PushPlugin" />
</feature>
</widget>

All the code is from the plugin example, i didn't change anything. My package name is io.cordova.hellocordova.

Any help would be greatly appreciated.

edit : it appears it might be a firewall problem. I'm waiting for the net team to open ports for the service

Upvotes: 2

Views: 1407

Answers (2)

inspiredMichael
inspiredMichael

Reputation: 388

What do you mean by it doesn't work? If you are talking about getting push messages, you will need a real device.

On Intel XDK,a popup window will show when you initialize the push plugin.

If you do a remote test on an Android device by using Intel App Preview, you will see the registration id.

Upvotes: 0

Jesper We
Jesper We

Reputation: 6087

The push plugin does not work in the emulator unless you install some extra libraries.

Have a look at the section titled "Installing helper libraries and setting up the Emulator" here:

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

Upvotes: 2

Related Questions