Last week at Apple’s Worldwide Developer Conference several continuity features were announced for iOS 8 and OS X Yosemite. One of them is called “Handoff.” This feature lets you hand-off an activity from one device to another. For example, if you’re looking at Safari on your iPhone but want to move over to your iPad or Mac you can resume browsing on the other device right where you left off.
I was excited by the possibilities but when I got into the details I found it is mostly targeted at Handoffs between:
- a native app to a website
- a website to a native app
A website to website Handoff is possible but limited.
State Transfer and eCommerce
The problem is during a Handoff, Safari just passes the URL over to the receiving device. "State" such as cookies, is not transferred. If you’re shopping at your favourite online store, add a few items to your cart and switch to another device, it’s going to load the online store, but not the contents of your cart.
Transferring Cart Contents in Spree
In order to transfer state we need to take advantage of the URL. I’ve been working on a proof of concept that does this in Spree Commerce. Once you’ve added something to your cart, we’ll append a parameter to all URLs which contains the order number for your current order.
The receiving device knows this order number does not belong to this new cart, which triggers the contents of that order to be transferred to the receiving cart.
Proof of Concept
Source code is available here https://gist.github.com/djones/80394768b4e2cd0505ab
The receiving device may already have some items in its cart, so how do you handle conflicts? Perhaps prompting the user if they want to use the new cart instead is a solution.
Another issue is the need for an extra parameter on all URLs. This is not desirable so perhaps this would only happen if a supported browser and operating system was detected.
I hope Apple will add more advanced support for Handoff in Safari in the future. One might first think bringing cookies over would be a sound thing to do, but it creates complexities when the receiving device already has those cookies. Either way iOS 8 and OS X Yosemite greatly improve the user experience between multiple devices and I look forward to seeing where it goes next.
Join The Conversation
More On The Blog
Investing in Digital Marketing in 2021.
In such a competitive environment, the need to increase your online visibility and optimize your site’s conversion rate often demands an investment in digital marketing tactics.
Alejandra Renteria — Jun 16, 2021
3 reasons your website still doesn't work on mobile
More than complying with Google, we believe that setting up your mobile site correctly is key for sites. From ranking higher, to optimizing performance and customer experiences, sites will undoubtedly work better when optimized for mobile from the ground up.
Alejandra Renteria — Jun 3, 2021
Why is it so hard to get an estimate for a software product?
Getting an accurate estimation for your software product can save you time, money and countless headaches when building your site, MVP or product.
David Hemmat — May 20, 2021