4

I would like to know if it is possible to share a url from the Safari app (or other apps) to my own app? The app I have developed allows the user to store or open a selection of urls.

I know this is possible for Android, but can I also add this to iOS?

EDIT: I want to open my own app to share the page I am currently visiting in the browser. If you press the button to share I would like to be able to select my app, such as in Android: http://developer.android.com/training/basics/intents/filters.html

Aidan
  • 118
  • 1
  • 11

2 Answers2

0

If I understand you correctly, this will be your solution:

First, you have to register your URL scheme in your info.plist file. You want to add the following settings:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>scheme</string>
        </array>
        <key>CFBundleURLName</key>
        <string>com.companyidentifier.appname.scheme</string>
    </dict>
</array>

Then you have to implement this delegate method to your AppDelegate:

- (BOOL)application:(UIApplication *)application  openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    // handle url here
    return YES;
}
Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
  • and with this code my app should show up in the share options in Safari? – Aidan Mar 16 '14 at 10:47
  • if([me isRight]) { return YES; } – Julian F. Weinert Mar 16 '14 at 14:00
  • 3
    else if ([you !isRight]) { return FALSE; }. This only allows you to open the url from the browser by entering a defined url sheme. What I am looking for, is a way to actually access my app from the share menu in Safari. Such as in Android: http://developer.android.com/training/basics/intents/filters.html – Aidan Mar 21 '14 at 15:44
  • I would also like to know if this is possible. I want to have my app show up in the share menu in Safari. So if you are on a web page and you select the share button, I want my app icon to show up there. I also know this is possible on Android. – Jesse May 29 '14 at 17:45
0

Details here: https://stackoverflow.com/a/38037060/3033056

Starting from iOS 8 you can achieve that by making a Share Extension app. This is a link to a tutorial ios8-share-extension-swift can help and you have to take a look at this link for sharing data between original app and app extension sharing-code-between-original-ios-app-and-app-extension

Community
  • 1
  • 1
Mohamed Elkassas
  • 829
  • 1
  • 13
  • 33