0

My issue is I need to find a way where I can have my action extension run in Safari and open up the website currently being viewed in Safari in my app (my app is a special web browser).

Here's a screenshot:
screenshot

When the rED extension is clicked, the extension opens up "rED://" which is my custom URL scheme. This launches the app and everything works fine.

However, I want the extension to grab the URL of the webpage being viewed in safari and open that website in my app, so the URL scheme call would look something like "rED://google.com".

What sort of code/methods would I need to implement, and in which .m file would it go in?

Cristik
  • 30,989
  • 25
  • 91
  • 127
Matthew
  • 41
  • 6
  • 1
    What do you have so far? – Evorlor Apr 28 '15 at 19:53
  • @Evorlor so far I only have code which loads "rED://" in a UIWebView which causes the view to switch from Safari to my app, rED. I have code in the rED AppDelegate which catches the custom URL path, so for example if the app is launched by opening "rED://google.com", the AppDelegate will grab "google.com" and the app will open google.com. However, I need the action extension to grab the URL from the webpage which is currently open, and then make the call "rED://". – Matthew Apr 29 '15 at 00:36

1 Answers1

0

Apple provides a method on NSExtensionContext for opening apps via URLs, however that only works for Today extensions (verified by an Apple employee at https://stackoverflow.com/a/24709883/3943258). This technically isn't currently possible.

Community
  • 1
  • 1
Tim Johnsen
  • 1,471
  • 14
  • 33
  • any idea how I can configure/implement a Today extension to complete the issue I outlined in the original post? – Matthew Apr 29 '15 at 12:28
  • You'd have to educate users to copy a link, then open the "Today" tab of their notifications list unfortunately. From there you can use the `NSExtensionContent` `-openURL:completionHandler:` method I mentioned. – Tim Johnsen Apr 29 '15 at 16:54