Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one do a Native App to Web Browser Handoff?

Tags:

ios

ios8

handoff

I have read the documentation and I understand that using Handoff I can exchange data between a specific website and app.

I have a curated list of items from various RSS feeds, all having links pointing to different websites. I would like to give the user the ability to open the link for an item (like a "More" button) in Safari on their mac instead of Safari on their iPhone.

Since all the links would be from different domains, certificates don't really apply. Is it possible to open Safari on a mac with a specific URL from an iOS app using Handoff? I couldn't really understand from the documentation if this was a possibility or not.

like image 469
user3539959 Avatar asked Oct 08 '14 14:10

user3539959


People also ask

What apps work with Handoff?

Third-party apps with Handoff functionality include Airbnb, NY Times, The Wall Street Journal, Wunderlist, iA Writer Pro, Quip, Camera Plus and more.

How do I use Handoff on safari?

Here's how to turn on Handoff: Mac: Choose Apple menu  > System Preferences, then click General. Select “Allow Handoff between this Mac and your iCloud devices.” iPhone, iPad, or iPod touch: Go to Settings > General > AirPlay & Handoff, then turn on Handoff.

How does Handoff work Apple?

With Handoff, you can start something on one device (iPhone, iPad, iPod touch, Mac, or Apple Watch) and then pick it up on another device right where you left off. For example, you can start answering an email on your iPhone, then finish it in Mail on your Mac.


1 Answers

Create an NSUserActivity object and specify the webPageURL property. Use an activityType specific to your app. If there is no app on the mac which supports that particular activityType, then Safari will pick it up.

NSUserActivity* myActivity = [[NSUserActivity alloc]
                  initWithActivityType: @"com.company.acme.myapp"];

myActivity.webpageURL = [NSURL URLWithString:@"http://www.google.co.uk"];

As per the docs for NSUSerActivity.webPageURL:

When no suitable application is installed on a resuming device and the webpageURL property is set, the specified webpage is loaded and the user activity is continued in a web browser.

Both flows (app-to-browser and browser-to-app) are documented at https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/Handoff/AdoptingHandoff/AdoptingHandoff.html

Your question comes under "Native App-to-Web Browser Handoff".

like image 163
Airsource Ltd Avatar answered Sep 23 '22 09:09

Airsource Ltd