在 FMX iOS App 中隐藏 App Switcher 的屏幕截图
Hide screenshot for App Switcher in FMX iOS App
在手机iOS系统中,双击home键,会进入App Switcher,会显示一系列的Appwindows。如果您自己的应用 window 有敏感信息,可能会在这个阶段泄露。
我已经设法使用 FMX.Platform
来捕获不同的应用程序事件。我试图更改为另一个 TabItem
而不是敏感的 TabItem
。我的代码可以编译,但 iOS 上的显示仍然保持不变。代码如下所示:
procedure TForm1.FormCreate(Sender: TObject);
var
aFMXApplicationEventService: IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then
aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent)
else
ShowMessage('Application Event Service is not supported.');
end;
...
function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
begin
if AAppEvent = TApplicationEvent.aeWillBecomeInactive then begin
tempActiveTbaItem := TabControl1.TabIndex;
TabControl1.TabIndex := 4; //4 is a blank tabItem
TabControl1.UpdateEffects;
end else
if AAppEvent = TApplicationEvent.aeEnteredBackground then begin
tempActiveTbaItem := TabControl1.TabIndex;
TabControl1.TabIndex := 4;
end else
if (AAppEvent = TApplicationEvent.aeBecameActive) and (tempActiveTbaItem <> -1) then begin
TabControl1.TabIndex := 0;
end;
Result := True;
end;
我在网上搜索了一下,在这里找到了两个解决方案:
Making sensitive data disappear in the iOS/iPadOS App Switcher
Hide Sensitive Information in the iOS App Switcher Snapshot Image
但这些仅适用于本机 Xcode。有人可以告诉我如何在 Delphi 中为 FMX 做吗?
对于 iOS,这应该可以解决问题:
uses
FMX.Platform.iOS;
// Other code snipped
if AAppEvent = TApplicationEvent.aeWillBecomeInactive then
begin
tempActiveTbaItem := TabControl1.TabIndex;
TabControl1.TabIndex := 4; //4 is a blank tabItem
WindowHandleToPlatform(Handle).View.setNeedsDisplay;
end;
调用setNeedsDisplay
强制视图重绘
在手机iOS系统中,双击home键,会进入App Switcher,会显示一系列的Appwindows。如果您自己的应用 window 有敏感信息,可能会在这个阶段泄露。
我已经设法使用 FMX.Platform
来捕获不同的应用程序事件。我试图更改为另一个 TabItem
而不是敏感的 TabItem
。我的代码可以编译,但 iOS 上的显示仍然保持不变。代码如下所示:
procedure TForm1.FormCreate(Sender: TObject);
var
aFMXApplicationEventService: IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then
aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent)
else
ShowMessage('Application Event Service is not supported.');
end;
...
function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
begin
if AAppEvent = TApplicationEvent.aeWillBecomeInactive then begin
tempActiveTbaItem := TabControl1.TabIndex;
TabControl1.TabIndex := 4; //4 is a blank tabItem
TabControl1.UpdateEffects;
end else
if AAppEvent = TApplicationEvent.aeEnteredBackground then begin
tempActiveTbaItem := TabControl1.TabIndex;
TabControl1.TabIndex := 4;
end else
if (AAppEvent = TApplicationEvent.aeBecameActive) and (tempActiveTbaItem <> -1) then begin
TabControl1.TabIndex := 0;
end;
Result := True;
end;
我在网上搜索了一下,在这里找到了两个解决方案:
Making sensitive data disappear in the iOS/iPadOS App Switcher
Hide Sensitive Information in the iOS App Switcher Snapshot Image
但这些仅适用于本机 Xcode。有人可以告诉我如何在 Delphi 中为 FMX 做吗?
对于 iOS,这应该可以解决问题:
uses
FMX.Platform.iOS;
// Other code snipped
if AAppEvent = TApplicationEvent.aeWillBecomeInactive then
begin
tempActiveTbaItem := TabControl1.TabIndex;
TabControl1.TabIndex := 4; //4 is a blank tabItem
WindowHandleToPlatform(Handle).View.setNeedsDisplay;
end;
调用setNeedsDisplay
强制视图重绘