pierre
pierre

Reputation: 47

How can I share Safari URL to my Cordova/PhoneGap App (ios)?

I am searching for the last week over many websites, and I can see people with the same question, but they are mostly misundestood.

What I have: I have an iOS application that can receive URL from browsers (made with ionic/cordova)

What I want: When I am on Safari (or other browser), i want to use the button Share, and my app appear there, in the list, just like Twitter, Facebook, etc. (I put an arrow in the image below).

Like this:

app sharing button

And, I want this working on many iOS versions.

So, I tried to change my app-info.plist many times and nothing works.

Somebody have a solution for this? Somebody have a info.plist that do this job?

(PS: I don´t want to use URL scheme, links, etc... Its the browser SHARE)

Thanks!

Upvotes: 1

Views: 572

Answers (1)

Warren Kim
Warren Kim

Reputation: 306

The only way is to create a share extension, as mentioned. It is not a trivial task in that you have to incorporate a lot of pieces together to make it work. Also, it is only supported on iOS 8+, which I guess shouldn't be a major issue at present.

In a nutshell:

  1. Create Share Extension in XCode
  2. Create a JS preprocessor
  3. Add plist key/value pairs for related ExtensionAttributes
  4. Set up custom URL scheme
  5. Customize ShareViewController
  6. Set up global handler function to perform your desired actions in app

See Cordova: sharing browser URL to my iOS app (Clipper ios share extension)

Or https://www.inshikos.com/blogs/76/dev/link-and-photo-sharing-to-a-cordova-ios-app-via-share-extensions-ios-8 that expands it further to include photo and wider share scenarios.

And, yes, a terribly misunderstood question with many false positive answers in other posts.

Upvotes: 1

Related Questions