应用运行时的Delphi Apple Push Notification [英] Delphi Apple Push Notification while app is running

查看:69
本文介绍了应用运行时的Delphi Apple Push Notification的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Delphi Rad Studio Seattle 10构建iOS应用。
此应用必须接收推送通知。这对我有用,但是当应用程序运行时,它确实会收到任何通知。我该怎么办?

I am building an iOS app with Delphi Rad Studio Seattle 10. This application must receive push notifications. That works for me, but when the app is running, it does receive any notifications. What can I be doing wrong?

这是代码:

var
  APushService: TPushService;
  AServiceConnection: TPushServiceConnection;
  ADeviceID, AdeviceToken: String;

APushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.APS);
AServiceConnection := TPushServiceConnection.Create(APushService);
AServiceConnection.Active := True;

ADeviceID := APushService.DeviceIDValue[TPushService.TDeviceIDNames.DeviceID];
AdeviceToken := APushService.DeviceTokenValue[TPushService.TDeviceTokenNames.DeviceToken];

使用此代码,应用程序会收到推送通知,但运行时不会。

With this code, the app receives push notifications, but not when it is running.

推荐答案

这是设计使然。当应用程序在前台时,推送通知将直接传递到该应用程序。如果希望在这种情况下通知用户,则必须在您的应用程序中进行处理。

This is by design. When an app is in the foreground, the push notification is directly delivered to the app. If you want the user to be notified in this case you have to handle this in your app.

仅当应用程序不在前台运行时,消息才会显示为通过警报或任何已配置的用户。然后,用户可以通过点击消息来启动应用。

Only when the app is not running in foreground, the message is shown to the user via an alert or whatever is configured. The user can then launch the app by tapping on the message.

这篇关于应用运行时的Delphi Apple Push Notification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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