"Hijack" system-wide http links on OSX and ideally iOS and open native App - ios

Assume I build a native Facebook App for the Mac or for iOS (just an example).
Now whenever the user opens an url http://facebook.com/.. I want my app to open rather than the browser. This is similar to opening google maps links prior to iOS 6 on iOS.
Unfortunately (like in the case with facebook) I do not own the service but I am only consuming its API so I can't forward to another URL from the actual website.
My question now is whether this is possible:
On the Mac with my native Mac App
On iOS (However, here I would be quite supprised if this was possible)

On iOS you can register a custom protocol which triggers if any other app (system, or not) tries to open that URL.
So in other words. Say your app registers the protocol 'myprotocol'. Then if you go to safari and type in the addressbar: myprotocol://sometext it will open your app, and your app can handle that URL.
This ALSO works from HTML loaded externally from Safari. So if your website is shown and on your website you link to myprotocol://sometext and someone clicks the link, then again your app will be opened.
Catching generic http requests system wide is unsupported on iOS

search for CustomURL / customProtocol for IOS apps. you will get your required answers. do let me know if you need a sample code.

Related

Can a progressive web app be registered as a share option on iOS?

I plan to develop an app (not sure if I will go with PWA yet) which includes the following "wishlist" scenario:
The user is browsing a website he likes using safari, chrome or any browser
He clicks the share button in that browser, in order to send the webpage url to another app
He selects my PWA
This url is saved in the user's wishlist
Is step 3 possible?
Note: someone asked the exact same question here about Android: Can a progressive web app be registered as a share option in Android?
My question is just the same, except mine is about iOS. I couldn't find any answers to it.
What you're describing is covered by Web Share Target Level 2.
Currently, it can be used with Chrome on some desktop platforms and on Android for installed PWAs.
It's not available on iOS, unfortunately.

Opening an app from URL schema

This may sounds crazy but just curious to know how a deep link/ URL schema reaches to an app to open it up in the device. Searched for an article but all contain how to make it work technically which I completely experienced, but could not find one how the handshake works.
If anybody can share if known, much appreciated!
Thanks.
The best information I could find so far on the subject is Wikipedia:
Unlike the Web, where the underlying technology of HTTP and URLs allow
for deep linking by default, enabling deep linking on mobile apps
requires these apps be configured to properly handle a uniform
resource identifier (URI). Just like a URL is an address for a
website, a URI is the address for an app on a mobile device. Examples
of URIs that launch a mobile app:
twitter:// is the iOS URI to launch Twitter’s mobile app
YouTube:// is
the iOS URI to launch YouTube’s mobile app
The format of the URI used
to trigger or deep link an app is often different depending on the
mobile operating system. Android devices work through intents,
BlackBerry 10 devices works through BB10's invocation framework,
Firefox OS devices works through Web Activities, iOS devices works
through the openUrl application method, and Windows Phone 8 devices
works through the UriMapper class.
fb://profile/33138223345 is an example of a mobile deep link. The URI
contains all the information needed to launch directly into a
particular location within an app, in this case the profile with id
'33138223345', i.e. the Wikipedia page, within the Facebook app,
instead of simply launching the Facebook app fb://. eBay's apps
demonstrate the use of different schemes by platform.
eBay://launch?itm=360703170135 is the URI that deep links into eBay’s
iOS app while eBay://item/view?id=360703170135 links into eBay’s
Android app
Basically the URL matching starts at the OS level.
iOS will use the settings in your apps plist file for a whole bunch of other things outside the app. One of them being the deep linking.
You declare your URL scheme in the plist, and whenever the OS encounters a URL matching this scheme (usually when user taps a button or link), it will open your app and pass the URL information on. It's then your responsibility to determine what to do with this information.
Does it jump into a profile page? A particular product? That's all left up to you.

How to share a link from the app using other applications

I want to share a link from my app using other applications installed on my iPhone such as Gmail, Facebook, DropBox, WhatsApp etc. In android there is a straight way to do so, just fire an intent and it automatically shows the installed apps through which we can share whatever we want. Is there any such way in iPhone ?
Thanks!
On iOS , app is more separated from each other. The only way to pass data from one app to other is using the URL mechanism. As one example, an app register url scheme "open-me://",you invoked openURL with "open-me://my-link" then that app will launched. That app will define the detail of the URL so it could understand the content.Continue with the example we are using, the text you passed could be either "open-me://A?data=my-link" or "open-me://A?message=my-link". So there are no general solution for all apps.Typically third party app will provide a SDK to make these things easy.
If you don't mind using a kind of large third party library, ShareKit is a good choice. It supports quite some apps.
If you want to know more about this topic,for example sharing files between app. You could start from reading the class reference of UIDocumentInteractionController.This UI component will show a list of app installed on your device which support the URL scheme.

How to publish link from iOS app to Facebook app with custom URL scheme?

I am creating an iOS app (using Adobe AIR) and I want to put a share button to my game that will allow the player to share a link to my game. I can do it with Graph API using my app's token, but I don't want a story published by my app. I want the native Facebook app to open and bring a share dialog. All my research concluded me to use the custom URL scheme such as fb://publish/?text=my_text but I couldn't get it working. I tried typing exactly that in Safari, it brings the native Facebook app, but no publish dialog or anything. All the sources online tells this, but it is not working. What could I be possibly doing wrong?

Force URL to open in a Web Clip if installed?

Let's say I have a web app that calls out to a native app via a custom URL scheme, and after the native app has done its thing it returns to my web app by opening a callback URL.
This all works fine when my web app is running in Safari. But what happens if a user saves the web app to the home screen (creating a "Web Clip")? In that case it runs in a separate process from regular safari, and has separate cookies and cache.
So when the native app tries to return to the web app, the URL will presumably get opened by Safari, not by the Web Clip, and the session will be lost. (And not just the session -- all the page state, which in a rich Javascript-based web app can be a lot of stuff with non-trivial startup time.)
Is this assumption correct? And if so, is there any way around it? Is there some way to get iOS to try to open the URL with a web clip if installed?
In order to have something launch via a custom url scheme on iOS, you must have an application register this information via the Info.plist built into the app.
It is not possible to have a webapp/webclip register this information system-level.
So, to answer your main question, you cannot do this.
Here is the information on implementing custom URL schemes in native applications.

Resources