0

In iOS15, there is a new API to SFSafariViewController.Configuration that suggest one can add a custom button on the SafariViewController UI. This blogpost explains this in greater detail, under "Running custom extension".

I've been trying to implement this in a sample app without success. See the code snippet below:

- (void)openSfariViewController {
    SFSafariViewControllerConfiguration *config = [[SFSafariViewControllerConfiguration alloc] init];
    // Also tried the following extensionIdentifiers without success
    // com.atomicbird.DemoNotes
    // com.apple.share-services
    SFSafariViewControllerActivityButton *button = [[SFSafariViewControllerActivityButton alloc] initWithTemplateImage:[UIImage systemImageNamed:@"heart.fill"] extensionIdentifier:@"com.atomicbird.DemoNotes.DemoNotes"];
    config.activityButton = button;
    SFSafariViewController *safariVC = [[SFSafariViewController alloc]initWithURL:[NSURL URLWithString:@"http://developer.apple.com"] configuration:config];
//    safariVC.delegate = self;
    [self presentViewController:safariVC animated:NO completion:nil];}

However I try to configure the new activityButton, it doesn't seem to have an effect on how SFSafariViewController appears when it is presented. It looks exactly like it does if I don't configure the activityButton. Here are some things I think I might got wrong:

  1. I don't know what is the extensionIdentifier, perhaps I used a wrong value?
  2. Perhaps I got the whole thing wrong, and an ActivityButton is not what I think it is?
  3. Maybe the Share extension is not the configured properly?

I haven't been able to find any information on the web on how an activityButton is even supposed to look like. Thanks for reading this far, let me know if you have any pointers for me.

gardenofwine
  • 1,344
  • 2
  • 15
  • 24
  • The extension identifier is the bundle identifier for a share extension included in your app bundle. – Paulw11 Oct 27 '21 at 04:07
  • Thanks! The bundle identifier in this case is `com.atomicbird.DemoNotes.$(PRODUCT_NAME:rfc1034identifier)`, which as I understand translates to `com.atomicbird.DemoNotes.DemoNotes` - which is what I'm using in the code. However, the other extension in the app (widget), has the SAME bundle id! I've tried modifying the extension bundle ids so that they are different from each other, but sadly that didn't solve my issue – gardenofwine Oct 27 '21 at 17:02

0 Answers0