问题GCM推送通知服务DELPHI XE6 [英] Issue with GCM Push notification service DELPHI XE6

查看:511
本文介绍了问题GCM推送通知服务DELPHI XE6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在delphi xe6上开发GCM推送通知。
我使用这篇文章中的代码 http:// stackoverflow .com / questions / 21466094 / start-android-activity-before-passing-the-gcm-intent (使用AndroidManifest.xml中的标准组件)为我自己的应用程序,我设法使用该服务接收即使应用程序未运行,通知也是如此。

I'm developing a GCM Push notification on delphi xe6. I use the code in this post http://stackoverflow.com/questions/21466094/start-android-activity-before-passing-the-gcm-intent (using the standars components in the AndroidManifest.xml) for my own app and I manage to use the service to receive the notification even if the app is not running.

但是当我收到通知时我遇到问题,我无法捕获onclick事件,所以我的应用程序打开(很棒),但不会

But I have a problem when I receive the notification and that is i cant capture the onclick event, so my apps open (great) but it doesn't do the desire action.

这是我的AndroidManifest.xml

Here is my AndroidManifest.xml

<receiver android:name="com.embarcadero.gcm.notifications.GCMNotification" android:exported="true">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="%package%" />
    </intent-filter>
</receiver>
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService">
</service>

如果我在帖子中使用代码,我可以检测用户何时点击通知,但是我不知道如何使用标准组件。

If I use the code in the post, i can detect when the user click on the notification, but I don't know how to do it with the standard components.

注意

推荐答案

在挖掘了很多源代码之后,在XE6 / XE7中实现GCM客户端的最佳和简单的方法是:




  • 将TKinvyProvider拖放到表单上,并填写只有 GCMAppID属性,留下其他默认值。

    The best and simplist way to implement GCM client without kinvy in XE6 / XE7 after I dug many source codes is:

    • Drop TKinvyProvider onto the form and fill ONLY GCMAppID property, leave others default.

      将TPushEvent组件放在窗体上,让 AutoRegisterDevice false

      Drop TPushEvent component onto the form and let AutoRegisterDevice to false.

      双击OnPushReceive事件TPushEvent,您可以从那里获取消息。

      Double click the OnPushReceive event in TPushEvent, and you can get message from there.

      双击TPushEvent中的OnDeviceTokenReceived事件,您可以获取推送服务器的设备令牌。

      Double click the OnDeviceTokenReceived event in TPushEvent, and you can get the device token nesseary for push server. Here you should send these infomation to your own GCM Sever by Indy for example.

      转到项目选项,在Entilement List中,检查支持推送通知。

      Goto Project option, in Entilement List, check support push notification.

      在您的项目目录中,有一个名为AndroidManifest的文件。 template .xml。只需在之前手动添加< service android:name =com.embarcadero.gcm.notifications.GCMIntentService/>
      ; / application>

      In your project directory, there's a file named AndroidManifest.template.xml. Just manually add <service android:name="com.embarcadero.gcm.notifications.GCMIntentService" /> right before </application>

      不需要更多自定义的java代码!

      No more customized java codes needed !

      PushEvents.StartupNotification在您的应用程序通过点击推送通知启动时效果很好。您还可以在该返回的对象中获取消息。如果您不使用此功能,则无法从OnPushRecevied evnet获取推送消息(不知何故似乎是一个错误)。

      PushEvents.StartupNotification works great when your app is launched by click on push notification. You can also get what message is in that returned object. If you don't use this, you can't get push message from OnPushRecevied evnet (somehow seems a bug).

      如果您需要GCM服务器进行测试只是留下评论。我会发送或上传文件。

      这篇关于问题GCM推送通知服务DELPHI XE6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆