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?
Here is the code:
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.