I'm trying to make background fetch work in my firemonkey application.
I've gotten so far that my perfromFetchWithCompletionHandler gets called and downloads new information.
The problem comes when I'm done with my fetch and need to call the completionHandler code block, the app hangs and I don't get any exception (that I can read at least)
Setup:
TBackgroundFetchResultHandlerC = procedure ( AResult : NSUInteger ); cdecl;
..
..
procedure performFetchWithCompletionHandler(self : id; _cmd : SEL; application: PUIApplication; handler : TBackgroundFetchResultHandlerC );
..
..
objc_msgSend((UIApp as ILocalObject).GetObjectId,
sel_getUid('setMinimumBackgroundFetchInterval:'),
Interval);
class_addMethod( objc_getClass('DelphiAppDelegate') ,
sel_getUid('application:performFetchWithCompletionHandler:'),
@performFetchWithCompletionHandler,
'v@:@?'
);
..
..
procedure performFetchWithCompletionHandler(self : id; _cmd : SEL; application: PUIApplication; handler : TBackgroundFetchResultHandlerC );
var t : TThread;
begin
NSLog3('performFetchWithCompletionHandler:begin');
Handler(0); <<--Stops here
//Next line of code never gets called.
NSLog3(Format('performFetchWithCompletionHandler:done, done',[ FetchResult ]) );
end;
performFetchWithCompletionHandler man page
I've tried with different declarations of the function pointer type, but as it isn't a function pointer exactly I guess that's why it won't work.
Any ideas?
Thanks Robert