Finally, I returned to this project and successfully registered service provider and handled service request.
First of all I tried to use NSRegisterServicesProvider method, but there is no such method in Macapi sources, so I searched for applicationDidFinishLaunching delegate. Using it I registered my service provider:
procedure TApplicationDelegate.applicationDidFinishLaunching(Notification: Pointer);
var
autoReleasePool: NSAutoreleasePool;
app: NSApplication;
provider: TMessageProvider;
begin
autoReleasePool := TNSAutoreleasePool.Create;
try
autoReleasePool.init();
app := TNSApplication.Wrap(TNSApplication.OCClass.sharedApplication);
provider := TMessageProvider.Create();
app.setServicesProvider(provider.ObjId);
finally
autoReleasePool.release();
end;
end;
Also I have created interface for service provider (I think it is required for ObjectiveC-Delphi bridge work):
IMessageProvider = interface(IObjectiveC)['{1EA9319A-8F99-4445-B435-48D5E73876FA}']
procedure simpleMessage(pBoard: Pointer; userData: Pointer; error: PPointer); cdecl;
end;
and inherited TMessageProvider from this interface and TOCLocal class.
After this my app can react to service request from context menu.
I’ve shared sources of my project. Here they are.