Android PushNotifications with PushPlugin on emulator


#1

Hello,
I’ve been following this sample to get android pushNotifications (with GCM) working on an android emulator.
After $cordovaPush.register(config) I get Ok as response. But it never runs my callback [$scope.$on('$cordovaPush:notificationReceived'].
And in consequence I never get my registration ID.

I’ve created a google API project. And I’m using that project Id in the config.senderID when calling $cordovaPush.register(config).

I’ve also registered a gmail account into my emulator.

I guess I have 2 questions.
1.Is it possible to get (and register) push notifications on an android emulator?
2. why don’t I get a $cordovaPush:notificationReceived event that calls my callback?


#2

@bsan I do not believe it is possible to test push notifications on a emulator. You need a test device,


#3

From PushNotifications plugin docs https://github.com/phonegap-build/PushPlugin

Important - Push notifications are intended for real devices. They are not tested for WP8 Emulator. The registration process will fail on the iOS simulator. Notifications can be made to work on the Android Emulator, however doing so requires installation of some helper libraries, as outlined here, under the section titled “Installing helper libraries and setting up the Emulator”.


#4

I don’t know how I missed such a clear paragraph…
Thanks for that.


Push Notification: Registration Returns OK but Never Received Registration ID ($cordovaPush) [SOLVED]
#5

I’ve copied the apk and installed it on my phone but I still have the same problem. it never fires notificationReceived.
Any ideas?


#6

I found a fix for it.
the name of the event is pushNotificationReceived NOT “$cordovaPush:notificationReceived”


#7

If you want to test on an Android emulator the notifications, you have to create the virtual machine with a Google API as target.


#8

you mean an AVD with Google Apis? are you just saying it or do you actually have a working AVD with pushnotifications?
Because I’ve found loads of blog posts “saying” that it works…but it doesn’t…not without you adding libraries and compiling manually…not with ionic build.

and yes. the same ionic app that works on my nexus 5…does not work on a AVD with Google APis targeting SDK21…


#9

hy @bsan i got the same problem. [$scope.$on(’$cordovaPush:notificationReceived’] never run so i cant get the registration id . Can you plz help or share this part of your thanks.