繁体   English   中英

如何获得firemonkey在iOS上显示本地通知?

[英]How can I get firemonkey to display a local notification on iOS?

我从Embarcadero网站(此处)提取了以下代码以生成本地通知。

procedure TForm1.SetNumberClick(Sender: TObject);
var
  MyNotification: TNotification;
begin
  // Create an instance of TNotification
  MyNotification := NotificationCenter1.CreateNotification;
  try
      MyNotification.Number :=18;
      MyNotification.AlertBody := 'Delphi for your mobile device is here!';
      NotificationCenter1.PresentNotification(MyNotification);
  finally
    MyNotification.DisposeOf;
  end;
end;

它编译并运行。 不出所料,我确实必须在表单上将NotificationCenter1创建为TNotificationCenter。 它可以在Android下找到,但是在iOS下却可以看到butkus。 没有本地通知,没有图标图标,甚至没有错误。

它曾经在XE8下工作吗?

XE8和10 / Seattle之间的本地通知是否有所更改?

我的手机正在运行iOS 9.2。 iOS在8.x和9.x之间进行了某些更改,从而中断了Firemonkey的本地通知吗?

我之前已经看过该教程 ,并且可以正常工作。

10 Seattle随附了两个示例应用程序。

我刚刚在iOS 9.2上使用Delphi 10 Seattle Update 1尝试了这两种方法,它们按我的预期工作。 (还曾在XE8中工作)。 您的代码也看起来正确。

也许在某个时候,您告诉iOS不要显示通知。 您是否签入了应用程序设置?

最终的解决方案有两个方面:

  1. 您必须将FMLocalNotificationPermission设置为true(项目->选项->版本信息)
  2. 该通知将会在应用没有在前台运行(例如,你已经回到你的主屏幕,关闭应用程序,等等)。 ScheduleNotification和PresentNotification方法都可以使用此方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM