Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Android push.on('registration', cb) fires correctly on device, but not in emulator. #204

Closed
alexklibisz opened this issue Oct 5, 2015 · 7 comments

Comments

@alexklibisz
Copy link

Is there any reason that this plugin would not work in an Android emulator but work on an actual device (using the same APK file)?

I'm using Cordova/Ionic to build an angular-based app. I began using the push plugin suggested by the ngCordova project: ttps://github.com/phonegap-build/PushPlugin.git, but I had problems with it, and it's deprecated, so I've switched to this one.

When I run my app on an Android Emulator (the default Android Emulator, on Linux), the push.on('registration') callback does not fire at all. When I build and run on my device (HTC One), it fires correctly. Here is my rather straightforward registration code, which is run after 'deviceready' event:

var push = PushNotification.init({
        "android": {
          "senderID": "111222333444555666"
        },
        "ios": {
          "alert": "true",
          "badge": "true",
          "sound": "true"
        },
        "windows": {}
      });

      push.on('registration', function(data) {
        console.log(data);
      });

I have the following Android packages installed:

Android SDK Tools, 24.4
Android SDK Build-tools, 23.0.1
Android SDK Build-tools, 23,
Android SDK Platform-tools, 23.1 rc1
Android 6.0 (API 23)
...SDK Platform
...Intel x86 atom system image
...Sources for Android SDK
Android 5.1.1 (API 22)
...SDK Platform
...Intel x86 atom system image
Extras
...Android SUpport Repository, 21
...Android Support Library, 23.0.1
...Google Repository, 22

Thanks

@macdonst
Copy link
Member

macdonst commented Oct 5, 2015

@alexklibisz Hmm, I always thought that push did not work on the emulator but check out this link and report back if this solution works for you:

http://stackoverflow.com/a/23443757/41679

@alexklibisz
Copy link
Author

@macdonst thanks for the quick response! I will try that. It has definitely worked for me in the past, but I recently had to re-install android SDK/studio/emulator and didn't document the working config I had before :/

I'll try later today and post back results.

@macdonst
Copy link
Member

macdonst commented Oct 5, 2015

@alexklibisz Sounds great, if this does work for you please close this issue.

@alexklibisz
Copy link
Author

@macdonst It did indeed solve the problem! Thank you for the pointer!

More specifically, here are the steps I followed:

  • In Android package manager, install the packages:
Android 5.1.1 (API 22)
- Google APIS
- Google APIS Intel x86 Atom Image
  • In android avd configuration, set my emulator target to use the Target: Google APIS (Google Inc)-API Level 22.
  • Rebuild and run app on emulator.

This is of course on top of the other packages I had installed.

Thanks again for the pointer.

@alexklibisz
Copy link
Author

Closing the issue, see the stackoverflow post linked by @macdonst and my details in the previous comment for resolution.

@macdonst
Copy link
Member

macdonst commented Oct 5, 2015

@alexklibisz thx

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants