[英]Set up urban airship push notifications with phonegap on android
I have a PhoneGap / Cordova app, and would like to add push notifications using the urban airship plugin for PhoneGap. 我有一个PhoneGap / Cordova应用程序,并希望使用PhoneGap的城市飞艇插件添加推送通知。 It looks promising.
看起来很有希望。 I try following the instructions from Urban Airship and look at the example at GitHub .
我尝试按照Urban Airship的说明 ,看一下GitHub上的例子 。 The problem is that I am a html5-css3-JavaScript developer, not a Java / Android developer.
问题是我是一个html5-css3-JavaScript开发人员,而不是Java / Android开发人员。 I'm using Eclipse.
我正在使用Eclipse。
I changed the AndroidManifest.xml file like in the example, putting my package name where appropriate. 我在示例中更改了AndroidManifest.xml文件,将我的包名称放在适当的位置。
I imported the .java files PushNotificationPlugin.java, IntentReceiver.java and MainApplication.java into my project tree in the src folder. 我将.java文件PushNotificationPlugin.java,IntentReceiver.java和MainApplication.java导入到src文件夹中的项目树中。 Now errors appear, for example "The import com.urbanairship.UAirship can not be resolved".
现在出现错误,例如“导入com.urbanairship.UAirship无法解决”。
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." “将PushNotificationPlugin.java和IntentReceiver.java文件安装到您的Android项目中。” 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?
我是否还应该在某处安装MainApplication.java文件以及如何安装?
"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? “在Application类中初始化Urban Airship库”我的PhoneGap项目树中的哪个文件是Application类,在这个文件中我可以复制粘贴Urban Airship代码?
"Instrument your main Activity class" I have to add those few lines of Java to the Cordova main activity. “检测主要的Activity类”我必须将这几行Java添加到Cordova主要活动中。 Which file contains the Cordova main activity and where in this file can I copy-paste that so much desired Urban Airship code?
哪个文件包含Cordova主要活动以及此文件中的哪个位置可以复制粘贴那么多所需的Urban Airship代码?
Any help would be greatly appreciated! 任何帮助将不胜感激! I'll even build you a simple Sencha Touch app if you help me get this working...
如果你帮助我开始工作,我甚至会为你建立一个简单的Sencha Touch应用程序......
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, eg: 在com.urbanairship.phonegap.plugins包中导入PushNotificationPlugin.java文件(将其放在src / com / urbanairship / phonegap / plugins中),使用您的包名更新IntentReceiver导入,并确保链接到res中的插件/xml/config.xml,例如:
<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.
启动应用程序时,您的设备APID应显示在Eclipse控制台中。 You don't need the Javascript files if you just want to be able to receive notifications.
如果您只是希望能够接收通知,则不需要Javascript文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.