简体   繁体   English

在android上设置带有phonegap的城市飞艇推送通知

[英]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: 这就是我最终完成它的工作,与教程中的内容相辅相成:

  1. copy the urbanairship[...].jar file in the libs folder of your project (this missing file is why you have errors on your printscreen) 将urbanairship [...]。jar文件复制到项目的libs文件夹中(这个丢失的文件就是您在打印屏幕上出错的原因)
  2. import the MainApplication.java, IntentReceiver.java files in your main package (come.waywayway.easyapp). 导入主包中的MainApplication.java,IntentReceiver.java文件(come.waywayway.easyapp)。 Update the package names in those files. 更新这些文件中的包名称。 I also had to replace ACTION_LOCATION_SERVICE_BOUND with ACTION_SUFFIX_LOCATION_SERVICE_BOUND in IntentReceiver 我还必须在IntentReceiver中用ACTION_SUFFIX_LOCATION_SERVICE_BOUND替换ACTION_LOCATION_SERVICE_BOUND
  3. 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"/> 
  4. update your main activity class(easyapp.java) to match the sample app main activity class (UAPhonegapSample.java) 更新主活动类(easyapp.java)以匹配示例应用程序主活动类(UAPhonegapSample.java)
  5. import and update your airship.properties and location.properties files as explained in the tutorial 按照教程中的说明导入和更新您的airship.properties和location.properties文件
  6. Based on the sample app AndroidManifest.xml file, update yours. 基于示例应用AndroidManifest.xml文件,更新您的。 Don't forget to add android:name=".MainApplication" as an attribute to the application object 不要忘记将android:name =“。MainApplication”添加为应用程序对象的属性

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.

相关问题 Urban Airship Android GCM 在 Android Oreo 和 Pie 上未收到推送通知 - Urban Airship Android GCM not receiving push notifications on Android Oreo and Pie Urban Airship Android推送通知确实需要哪些服务和活动? - What services and activities are really required for Urban Airship Android push notifications? 带有phonegap的Android应用不会向城市飞艇注册进行推送 - Android app built with phonegap won't register for push with urban airship 使用PhoneGap在Android 4.4上方的Urban Airship推送通知图标 - Urban Airship push notification icon in above Android 4.4 with PhoneGap PhoneGap-Android:从我的服务器通过Urban Airship推送通知 - PhoneGap-Android: Push Notification by Urban Airship from my server 如何在 Phonegap 项目中为 Android 安装新的 Urban Airship 推送库 - How to install the new Urban Airship Push Library for Android in a Phonegap Project 通过GCM和Urban Airship的Android推送通知 - Android push notification via GCM and Urban Airship Android中的Urban Airship Rich Push Notification错误 - Error in Urban Airship Rich Push Notification Android 适用于Android的PHP中的城市飞艇推送通知 - Urban airship push notification for Android in PHP Android中的城市飞艇推送通知问题? - urban airship push notification problem in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM