My installer load XPC service and XPC client that attempt to call remote xpc method on that service.
However, the service my be loaded arbitrarily and the client may get invalid connection since the service hasn't loaded yet.
So far I haven't found any way get service-load indication, so I'm calling the retry method recursively from within the connection invalidationHandler.
Is this the correct approach ? is there any wait-for-service event I can wait for ?
However, the service my be loaded arbitrarily and the client may get invalid connection since the service hasn't loaded yet.
So far I haven't found any way get service-load indication, so I'm calling the retry method recursively from within the connection invalidationHandler.
Is this the correct approach ? is there any wait-for-service event I can wait for ?
Code Block +(void) callXpcWithRetry { NSXPCConnection* hubConnection = [[NSXPCConnection alloc] initWithMachServiceName:@"com.bla.myservice" options:0]; hubConnection.remoteObjectInterface = getInterface(); [hubConnection setInvalidationHandler:^{ NSLog(@"Connection to keystore hub service invalidated .. retry in 5"); sleep(5); [ServiceDelegate callXpcWithRetry]; }]; [hubConnection resume]; id<myXpcProtocol> hub = [hubConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { }]; [hub xpcProtocolMethodForUser:NSUserName()]; }