Host app URL scheme does not opening from the Share Extension?
Add a Comment
How to open containing app from Share Extension?
Please use below code
NSURL *destinationURL = [NSURL URLWithString:@"AppUrlScheme://App bundle identifier"];
NSString *className = [[NSString alloc] initWithData:[NSData dataWithBytes:(unsigned char []){0x55, 0x49, 0x41, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E} length:13] encoding:NSASCIIStringEncoding];
if (NSClassFromString(className)) {
id object = [NSClassFromString(className) performSelector:@selector(sharedApplication)];
[object performSelector:@selector(openURL:) withObject:destinationURL];
}
Please use below code
Do not do this! Code running in the context of an app extension does not have access to
UIApplication
. Using the Objective-C runtime to bypass that restriction is not supported by Apple. This presents two serious dangers:
The system might change in such a way to break your app. Apple does its best to maintain binary compatibility for supported techniques, but we offer no such guarantees for unsupported ones.
App Review requires that your app stick to public APIs and might reject it otherwise.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"