3 Replies
      Latest reply on Mar 14, 2019 2:54 AM by eskimo
      • Re: Host app URL scheme does not opening from the Share Extension?
        prasadk60 Level 1 Level 1 (0 points)

        How to open containing app from Share Extension?

        • Re: Host app URL scheme does not opening from the Share Extension?
          prasadk60 Level 1 Level 1 (0 points)

          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];
          }

            • Re: Host app URL scheme does not opening from the Share Extension?
              eskimo Apple Staff Apple Staff (10,875 points)

              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"