我想推送消息添加到我的PhoneGap Android应用程序,并相信C2DM是为了使这项工作的waybest方式 - 可以点我在正确的方向来设置呢? 是否有插件或教程,以帮助这个吗?
I would like to add Push messaging to my Phonegap Android App and believe that C2DM is the waybest way to make this work - could point me in the right direction to set this up? Is there a plugin or tutorial to help with this?
此外 - 我是不是真的需要一个插件 - 是否有可能C2DM添加到我的应用程序的Android的传统方式没有搞乱我的PhoneGap设置
Also - do I actually need a plugin - is it possible to add C2dm to my app the traditional Android way without messing up my phonegap setup?
推荐答案
是的,C2DM是Android推送解决方案。在 https://github.com/awysocki/C2DM-PhoneGap 你可以找到一个示例实现。
Yes, C2DM is the Android Push solution. On https://github.com/awysocki/C2DM-PhoneGap you can find an example implementation.
在com.google命名空间中的文件已被列入不变,他们从会议谷歌IO会议概述:安卓+应用程序引擎:开发者的梦幻组合,见http://bradabrams.com/2011/05/google-io-session-overview-android-app-engine-a-developers-dream-combination/
The files in the com.google namespace have to be included unchanged, they are from the session "Google IO Session Overview: Android + App Engine: A Developer’s Dream Combination", see http://bradabrams.com/2011/05/google-io-session-overview-android-app-engine-a-developers-dream-combination/
因此,这些都是你的步骤应该执行:
So these are the steps you should perform:
添加3 com.google类项目 创建了一个名为 C2DMReceiver
(命名约定),它继承了 C2DMBaseReceiver
和实施必要的抽象事件
设置了AndroidManifest.xml中
Add the 3 com.google classes to your project
Create a class called C2DMReceiver
(naming convention) which inherits from C2DMBaseReceiver
and implement the necessary abstract events
Set up the AndroidManifest.xml
在AndroidManifest看起来像
The AndroidManifest looks like
<!-- set up an own permission to secure our C2DM mesages -->
<permission android:name="your.namespace.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!-- List of permission -->
<uses-permission android:name="your.namespace.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application ..>
<!-- Your implementation of the class C2DMReceiver, base class is Googles C2DMBaseReceiver -->
<service android:name=".C2DMReceiver" />
<!-- Googles broadcast receiver, it delegates to your.namespace.C2DMReceiver -->
<receiver
android:name="com.google.android.c2dm.C2DMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="your.namespace" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="your.namespace" />
</intent-filter>
</receiver>
</application>
如果您收到模拟器上的错误E / CSE通知(401):注册错误ACCOUNT_MISSING,你必须一个谷歌帐户添加到您的模拟器
If you receive on the emulator the error "E/CSE Notifications(401): Registration error ACCOUNT_MISSING", you have to add a Google account to your emulator.
有关你的第二个问题:这取决于你想要做什么。当您收到的消息,你只是想显示通知,使用户能够启动您的应用程序,那么你并不需要一个PhoneGap的插件。在这种情况下,你可以解决一切的Java。
For your second question: it depends what you want to do. When you receive the message and you just want to display a notification so that the user is able to start your app then you don't need a Phonegap plugin. In that case you can solve everything in java.
相关推荐
最新文章