Ios Delphi-在应用程序运行时处理推送通知?

Ios Delphi-在应用程序运行时处理推送通知?,ios,delphi,firemonkey,Ios,Delphi,Firemonkey,这就是我们在XCode中处理它们的方式: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSString *message = nil; id alert = [userInfo objectForKey:@"alert"]; if ([alert isKindOfClass:[NSString class]]) {

这就是我们在
XCode
中处理它们的方式:

- (void)application:(UIApplication *)application
   didReceiveRemoteNotification:(NSDictionary *)userInfo
{
  NSString *message = nil;
  id alert = [userInfo objectForKey:@"alert"];
  if ([alert isKindOfClass:[NSString class]]) {
    message = alert;
  } else if ([alert isKindOfClass:[NSDictionary class]]) {
    message = [alert objectForKey:@"body"];
  }
  if (alert) {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title"
                                       message:@"AThe message."  delegate:self
                             cancelButtonTitle:@"button 1"
                             otherButtonTitles:@"button", nil];
    [alertView show];
    [alertView release];
  }
如果
iOS
应用程序已经以相同的方式运行,但使用的是
Delphi 10 Seattle
,我们如何捕获推送通知?

注意:很遗憾,我无法测试这一点,因为我目前没有Mac电脑,但这应该可以工作

FMX.Platform.iOS中
您可以找到

ApplicationDidReceiveRemoteNotification
方法,因此它是在Delphi中实现的

procedure TApplicationDelegate.applicationDidReceiveRemoteNotification(
  Sender: UIApplication; ANotification: NSDictionary);
begin
  PlatformCocoa.ReceivedRemoteNotification(ANotification);
end;
在那里,您可以通过
NSDictionary
获取通知,然后可以从该
NSDictionary
读取值,以您想要的方式处理它

你也可以参考Remy关于我的一个问题,关于方法swizzling告诉应用程序使用你的
ApplicationIDReceivereMotentification
版本,而不是源文件中的版本

TEMSProvider
组件放到表单上
TPushEvents
组件放到表单上
TPushEvents.Provider
绑定到
TEMSProvider

在代码某处设置
TPushEvents.Active:=True
或启用其自动激活属性


TPushEvents有一个名为
PushEvents1PushReceived
handle it

的事件。您应该更改问题的标题,以包括Delphi 10。现在也是misleading@SausageMachine完成。我将把它保留为Delphi,这样就不会局限于它的最后一个版本。@SausageMachine,这就是标签的用途。@Johan。例如,当您通过iOS标记进行浏览时,您将看到标题列表。这个问题对Delphi来说实在太具体了,不了解Delphi的人会点击标题,假设它是关于iOS和push的。但是如果你不了解德尔福,那么你就不能回答这个问题,因此你点击了这个问题并阅读了它,结果浪费了你的时间,因为直到你找到问题的底部,很明显它是关于德尔福的。因此,将其放在标题中可以从开头和搜索视图中清楚地看到。@SausageMachine,阅读Meta上的讨论。标签是缩小问题范围的正确位置,而不是标题。标题应该只列出问题。