Search code examples
iosdelphibackgroundfiremonkey

Delphi Firemonkey ios Background Fetch


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;

Solution

  • 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