Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set an "mobile deep link" to downloadable file from woocommerce?

I have woocommerce setup up on a wordpress site for downloading PDF files. After a user goes through the checkout process and is ready to download the file, I'd like to check to see if they are on a mobile device or not. If the user is not on a mobile device, the download link would just be normal.

If the user is on a mobile device, I'd like to set the download link to be an "app deep link" using a custom URI scheme (from an existing vendor). For example, instead of the download link referencing http:// or https://, I'd like the download link to be appname://domain.com/folder/filename.pdf. This way, the PDF would automatically open in my app when they clicked on the link. The app vendor already support the custom URI schema, so I am just looking for "how" to set the link dynamically in WordPress/Woocommerce.

How would I go about:

  1. detecting if the user is on a mobile device, and
  2. changing the URI scheme if they are a mobile user?

The concept I am trying to accomplish is described here in the "Native App" example: http://www.mobiloitte.com/blog/deep-linking-101

and here: https://en.wikipedia.org/wiki/Mobile_deep_linking

like image 530
RyanKDalton Avatar asked Jan 02 '23 14:01

RyanKDalton


1 Answers

For your first question, trying using javascript window.navigator.userAgent or with PHP try using $_SERVER['HTTP_USER_AGENT']. This should work independent of Wordpress or other site details. See related questions here and here.

For your second question, deep linking is used for individual mobile apps, right? The answer probably depends on which app you're targeting. If it's an existing app, you might get the best traction contacting the app developer. If you're writing a new app, there is information for android here and for iOS here. If you want a permalink URL that refers to specific content on your Wordpress page (like a specific transaction event and user name) then you can find information about permalinks and query strings with WordPress, for example here.

like image 74
MichaelsonBritt Avatar answered Jan 05 '23 18:01

MichaelsonBritt