Delphi Firemonkey ios后台获取 [英] Delphi Firemonkey ios Background Fetch
问题描述
我正在尝试使用delphi Firemonkey开发iphone应用程序.如果有新的数据发送通知,我需要每隔X分钟下载一个xml并进行处理.如果正在使用该应用程序,这非常容易,但是当该应用程序在后台时,我找不到使用此过程的方法....
i'm trying to use delphi Firemonkey to develop an iphone App. I need to download an xml every x minutes and process it, if there are new data send notification. It's very easy if the app is in use, but i can't find the way to use this procedure when the app is in background....
请帮助我...
很多Tnx ...但是我做不到.... 这是我最简单的代码,不起作用...我的错误是什么??
Tnx a lot...But i can't do this.... this is my simpliest code that doesn't work... What is my error???
procedure TForm1.Button1Click(Sender: TObject);
var
IdHTTP1 : TIdHTTP;
MyFile : TFileStream;
Notification: TNotification;
UIApp : UIApplication;
begin
UIApp := TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication);
UIApp.setIdleTimerDisabled(True);
TThread.CreateAnonymousThread(procedure ()
var
I: Integer;
Total: Integer;
begin
Total := 0;
while true do
begin
// Carico l'XML
MyFile:= TFileStream.Create(TPath.GetDocumentsPath + TPath.DirectorySeparatorChar+'listticket',fmCreate);
IdHTTP1 := TIdHTTP.Create(nil);
IdHTTP1.Get('http://www.google.com', MyFile);
IdHTTP1.Free;
MyFile.Free;
end;
sleep(5*60*1000);
TThread.Synchronize (TThread.CurrentThread,
procedure ()
begin
end);
end).Start;
end;
推荐答案
请参阅这些文章以帮助您入门.
See these articles to get you started.
在Delphi XE5 Firemonkey应用程序中禁用IOS设备空闲超时
使用ObjectiveC桥在iOS上以编程方式禁用空闲计时器
处理Android和IOS生命周期Delphi XE5 Firemonkey中的事件
这篇关于Delphi Firemonkey ios后台获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!