2
votes

I'm trying to add push notifications to my app but I can't get the sample project to work.

This is what I did:

  • Downloaded sample project
  • Opened in Worklight 5.0.6
  • Registered project id and API key at Google
  • Entered id and key in application-descriptor.xml like so:

    <pushSender key="XXX senderId="YYY"/>

  • Deployed adapter
  • Built the app ("Build all and deploy", Android SDK API 18, Google API 18)
  • Checked worklight console's Push Notifications tab (app and adapter are listed there) and the push notification tab http://s14.directupload.net/images/131022/nex9fth5.png
  • Started the app in android emulator (4.3)
  • In sample app, logged in with user "spyro", password "test"
  • Got an error:

Failed registering for push notifications. The application will not be able to receive notifications

LogCat gives me the following messages:

10-22 06:07:11.178: E/SQLiteLog(2600): (14) cannot open file at line 30191 of [00bb9c9ce4] 10-22 06:07:11.178: E/SQLiteLog(2600): (14) os_unix.c:30191: (2) open(/CachedGeoposition.db) - 10-22 06:10:58.392: W/WLDroidGap(2600): unregisterReceivers:Receiver not registered: com.worklight.androidgap.plugin.Push$1@b419ff38 10-22 06:10:58.402: W/WLDroidGap(2600): unregisterReceivers:Receiver not registered: com.worklight.androidgap.plugin.Push$3@b41a0458 10-22 06:10:58.442: E/PushApplication(2600): Error while trying to retrieve device token from the mobile operating system.

1

1 Answers

3
votes

I believe the following will resolve your problem, which is setting up push notifications in the Android Emulator; to have push notifications in the emulator it is required to install from the Android SDK Manager some support libraries.

  1. First, make sure that you have followed all steps described in the Push Notifications training module, specifically slides 41 and 47.
  2. Follow the steps described in the answer to this SO question:

enter image description here


In your updated question you do not mention whether you've installed the push notifications feature library, and you must install it.