Gab*_*iel 0 delphi notifications firemonkey google-cloud-messaging delphi-xe6
我正在delphi xe6上开发一个GCM Push通知.我使用此帖子中的代码/sf/ask/1502626611/(使用AndroidManifest.xml中的标准组件)为我自己的应用程序和即使应用程序未运行,我也设法使用该服务接收通知.
但是当我收到通知时我遇到了问题,那就是我无法捕获onclick事件,因此我的应用程序打开(很棒),但它不会执行欲望操作.
这是我的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>
Run Code Online (Sandbox Code Playgroud)
如果我使用帖子中的代码,我可以检测用户何时点击通知,但我不知道如何使用标准组件.
问候
小智 5
将TKinvyProvider拖放到表单上并仅填写GCMAppID属性,保留其他默认值.
将TPushEvent组件拖放到窗体上,并将AutoRegisterDevice设置为false.
双击TPushEvent中的OnPushReceive事件,您可以从那里获取消息.
双击TPushEvent中的OnDeviceTokenReceived事件,您可以获得推送服务器的设备令牌nesseary.在这里,您应该通过Indy将这些信息发送给您自己的GCM服务器.
转到项目选项,在附件列表中,检查支持推送通知.
在项目目录中,有一个名为AndroidManifest的文件.模板 .xml.只需手动添加<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
前右</application>
不再需要定制的java代码!
通过单击推送通知启动应用程序时,PushEvents.StartupNotification非常有效.您还可以获取该返回对象中的消息.如果你不使用它,你不能从OnPushRecevied evnet获得推送消息(不知何故似乎是一个错误).
如果您需要GCM服务器进行测试,请发表评论.我会发送或上传文件.