Delphi Firemonkey ios Background Fetch

老子叫甜甜 提交于 2019-12-11 20:59:57

问题


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....

Please help me...

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;

回答1:


See these articles to get you started.

Disable The IOS Device Idle Time Out In Your Delphi XE5 Firemonkey App

Programatically Disable the Idle Timer on iOS using the ObjectiveC Bridge

Providing background services support to your iOS apps with Delphi

Handle Android And IOS Lifecycle Events In Delphi XE5 Firemonkey



来源:https://stackoverflow.com/questions/24168144/delphi-firemonkey-ios-background-fetch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!