Is there a way to determine if an app is installed on a phone using Javascript within Safari on iOS 9 or later?

Prior to iOS 9, one method of determining whether an app was installed on an iPhone using javascript involved utilizing a custom URI scheme followed by a timeout:

window.location = "yourapp://";
setTimeout(function() {
  window.location = "https://yourdomain.com";
}, 25);

If the app was installed, it would launch and prevent the timeout from triggering since javascript execution halts when the app opens.

However, in Safari on iOS 9 and above, the line

window.location = "yourapp://";
triggers a popup prompting the user to decide whether to open the app. Consequently, javascript continues executing, causing the timeout to run before the app opens, leading to the App Store opening instead.

In summary - In iOS 9 and later versions, within Safari, even if the app is installed, this code will still redirect to the App Store. Therefore, this approach is no longer effective for checking app installation status.

Is there an alternate method to determine if an app is installed on an iPhone running iOS 9 or newer using Javascript on a webpage?

Answer №1

If you want to retrieve information about the user's device and operating system, you can employ the following code:

navigator.userAgent

// By using this code snippet, you will be able to access details such as Device type and OS version.

// Here is an example of the output for iPhone X:
// Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for sending the ampersand character (&) as a parameter in an AngularJS resource

I have an angular resource declared in the following manner: angular.module('xpto', ['ngResource']) .factory('XPTO', function ($resource, $location) { var XPTO = $resource($location.protocol() + '://' + $locatio ...

Clicking on a link in HTML with the onclick event

I am looking to create a button that will direct me to a different page. Here is the code snippet I have: <div align="right" ><input type="submit" id="logout" onclick="location.href='/login?dis=yes'" value="Sign Out" ></div>& ...

Building a custom Vue layout within Laravel UI

Currently, I am utilizing Laravel 8 along with laravel/ui 3.4 for the front end of my project. My goal is to establish a fixed sidebar, footer, and a designated area for the router-view. In my routes/web.php file: Route::view('/{any}', 'hom ...

Leveraging Angular CLI in conjunction with the newest AspNetCore Angular 4 Single Page Application template

I'm currently experimenting with using Angular CLI alongside the latest JavaScriptServices AspNetCore Angular Spa template. In the past, I would simply copy and paste a .angular-cli.json file into my project's root directory, change "root" to "C ...

Adding the ability to export CSV files from Bootstrap Table to an Angular 15 project

Struggling to incorporate the Bootstrap-table export extension into my Angular project without success so far. Visit this link for more information Any assistance or examples would be greatly appreciated. Thank you in advance! This is what I have tried ...

Concealing the parent template in Vue Router when the child is displayed

Having some trouble setting up Vue.js with the router, specifically dealing with view display issues. I've created a router.js file with child routes for breadcrumbs and route clarity purposes. Each individual route loads perfectly fine when opened. ...

The onmessage event in the websocket client seems to be malfunctioning and is not triggering

In my implementation using node.js, I have set up a websocket server and client. The handshake process between the server and client appears as follows: Request URL: ws://localhost:8015/ Request Method: GET Status Code: 101 Switching Protocols Request ...

Does Material-UI MenuItem pass arguments to the onClick handler function?

I am currently working with a search.js file and a search-date.js file. Within the search.js file, there is a container called SearchDate which I render. However, I'm puzzled by the behavior of the MenuItem component when it is clicked. The function ...

Storing CMTime in CoreData using Xcode 8 and Swift 3

In my data model, I have declared two attributes named currentTime and fullTime as being of type Transformable. https://i.sstatic.net/GeTNq.png I am wondering how to save data in these attributes. Do I need to first convert them to NSData, or is there an ...

Transfer information from one Angular JS page to another pager based on ID

In my use of the mobile angular js UI framework, I am a beginner in angular js and looking to transmit data from one page to another using city id. When a user clicks on a city, the data should be displayed according to that specific city. HOME PAGE: ht ...

Working with nested arrays in Mongoose/Javascript: Adding an Object to an Array within another Array

I have been attempting to add an object to an array that is nested inside another Array in Mongoose. Essentially, it's like having comments for the comments. Below is the structure of my schema: const Schema = new mongoose.Schema ({ name: {type: Str ...

Utilizing Jquery to auto-scroll when an element reaches the top of

I have arrows positioned at the end of sections on my website that I want users to be able to click on in order to scroll to the next section. The issue I am facing is that while the first click works, subsequent clicks do not result in scrolling even thou ...

Ways to eliminate all attributes and their corresponding values within HTML tags

Hey there, I'm trying to strip away all the attribute values and styles from a tag in html Here's my Input: <div id="content"> <span id="span" data-span="a" aria-describedby="span">span</span> <p class="a b c" style=" ...

Convert JSON information for use in ChartJS

I've been delving into the world of ChartJs and have encountered a bit of a roadblock. I'm looking to decipher how to convert JSON data into labels and data for a bar chart. The JSON data consists of an array of product orders. With varying numb ...

JavaScript program failing to execute

Seeking to incorporate a read more and read less feature that activates on click for my articles application using Django. However, encountering an issue where my JavaScript code does not work when the read more link is clicked. Below are the relevant fil ...

Repeated Identification Numbers in Mongoose Database

I have created a virtual object with a duplicated ID and I'm struggling to find a solution using the new syntax. Can anyone offer assistance? /** * Import only the mongoose in this class * This plugin is for MongoDB and this class decide how the Mon ...

Is it possible to incorporate swigjs within scripts?

Currently, I am stuck while working on my website using a combination of nodejs, express, and swigjs. The issue I am facing involves a <select> element that is populated by options from a variable passed to my template. When a user selects an option, ...

"Combining background images with javascript can result in displaying visual elements

Hello! I am in need of assistance with a CSS + Javascript fog effect that I have developed. It is functioning properly on Firefox, Opera, and Chrome but encountering issues on IE and Edge browsers. The effect involves moving two background images within a ...

Storing a component in browser storage using JavaScript and Angular

I am currently working on developing an Angular application that allows users to "favorite" a business card and store it in local memory. I am facing challenges with actually storing the clicked element in the browser's local memory. Furthermore, I f ...

In right-to-left mode, two items in Owl Carousel vanish while dragging or touching

When using owl carousel 2 with the RTL option, I encountered an issue where the carousel disappears when dragging/touching the last item (5 or 6 slides to the right, it disappears). I prefer not to use the loop option to workaround this. How can I resolve ...