Reputation: 792
I have a PhoneGap / Cordova app, and would like to add push notifications using the urban airship plugin for PhoneGap. It looks promising. I try following the instructions from Urban Airship and look at the example at GitHub. The problem is that I am a html5-css3-JavaScript developer, not a Java / Android developer. I'm using Eclipse.
I changed the AndroidManifest.xml file like in the example, putting my package name where appropriate.
I imported the .java files PushNotificationPlugin.java, IntentReceiver.java and MainApplication.java into my project tree in the src folder. Now errors appear, for example "The import com.urbanairship.UAirship can not be resolved".
See the screenshow below for my progress so far and for the errors.
My questions are:
"Install the PushNotificationPlugin.java and IntentReceiver.java files into your Android project." Where do I have to place these files in the project tree, and do I have to link to them in any way? Should I also install the file MainApplication.java somewhere and how?
"Initialize the Urban Airship library in your Application class" Which file in my PhoneGap project tree is the Application class and where in this file can I copy-paste the Urban Airship code?
"Instrument your main Activity class" I have to add those few lines of Java to the Cordova main activity. Which file contains the Cordova main activity and where in this file can I copy-paste that so much desired Urban Airship code?
Any help would be greatly appreciated! I'll even build you a simple Sencha Touch app if you help me get this working...
Upvotes: 1
Views: 3499
Reputation: 1076
I had trouble setting it up too. This is what I did to finally get it working, in complement to what is said in this tutorial:
import the PushNotificationPlugin.java file in a com.urbanairship.phonegap.plugins package (place it in src/com/urbanairship/phonegap/plugins), update the IntentReceiver import with your package name, and make sure to link to the plugin in res/xml/config.xml, e.g.:
<plugin name="PushNotificationPlugin" value="com.urbanairship.phonegap.plugins.PushNotificationPlugin"/>
Once this is done, you should be able to send a test notification from urban airship console. Your device APID should show up in Eclipse console when you launch your app. You don't need the Javascript files if you just want to be able to receive notifications.
Upvotes: 3