Hi there,
I have found that the +[SFSafariApplication getHostApplicationWithCompletionHandler:] message pretty often returns (more precisely, of course, calls the completion handler with) a nil. Actually it looks like
- upon the extension launch it keeps returning nil ...
- ... until the first message from an injected JS is received, or the toolbar button is clicked, or something like that
- then it for awhile returns Safari; but in a short moment, it gets back to nil.
To add insult to injury, the handler is even declared as nonnull 🙂
The test code is trivial, inside of a Safari App Extension:
@interface SafariExtensionHandler:SFSafariExtensionHandler @end
@implementation SafariExtensionHandler
+(void)load {
NSLog(@"launched");
[self checkSignature];
}
+(void)checkSignature {
[SFSafariApplication getHostApplicationWithCompletionHandler:^(NSRunningApplication * _Nonnull host) {
NSLog(@"host: %@",host);
[self performSelector:_cmd withObject:nil afterDelay:2];
}];
}
... ...
The logs look like NULL, NULL, NULL ... until a script sends a message or so, then I am getting Safari for awhile, but after a moment, again NULL, NULL, NULL...
Might this be my fault? Or is that a documented behaviour whose documentation I have missed somewhere?
Thanks for any insight,
OC