반응형

스마트폰 BTC 채굴앱
https://get.cryptobrowser.site/34473645

 

Earn coins while browsing the web

Earn bitcoins while watching videos, chatting, or playing online. It has never been so easy to increase your income! Tell your friends about CryptoTab Browser, invite them to join, and earn more together. Grow your network—get more profit!

get.cryptobrowser.site

 

모바일 웹 페이지에서 스마트폰의 특정앱이 설치되어 있을 경우 앱을 실행하고
그렇지 않으면 스토어로 이동 시켜야 하는 경우 다음과 같이 처리하여 해결할 수 있다.

 

Android :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.mytest.mypackageid">
	...
</manifest>

<application>
	....
	<activity
		...
		<intent-filter>
			...
			<data android:host="action" android:scheme="myScheme" />
		</intent-filter>
	</activity>
    ....
</application>
방법 1:
location.href = "Intent://action#Intent;scheme=myscheme;package=com.mytest.mypackageid;end";

방법 2:
location.href = "https://play.google.com/store/apps/details?id=com.mytest.mypackageid";

 

참고 자료 :

https://developer.chrome.com/multidevice/android/intents

 

Android Intents with Chrome - Google Chrome

Chrome Extend the Browser What are Extensions? Get Started Tutorial Overview Manifest Format Manage Events Design User Interface Content Scripts Declare Permissions and Warn Users Give Users Options Developer Guide Reach Peak Performance Protect User Priva

developer.chrome.com

 

iOS :

//
// 방법 1 : Timer 이용한 방법
//
function openAppOrStore() {
	var timeout = setTimeout(function () { 
    	window.location = "https://itunes.apple.com/app/id123456789"; 
	}, 25);
	window.location = "myappscheme://";
	clearTimeout(timeout);
}

//
// 방법 2 : iframe을 이용한 방법
//
function openAppOrStore() {
  var appURL = "yourappname://";
  var appStoreURL = "https://itunes.apple.com/app/yourappname/id1234567890";
  
  // 앱이 설치되어 있는지 확인
  var iframe = document.createElement("iframe");
  iframe.style.display = "none";
  iframe.src = appURL;
  document.body.appendChild(iframe);
  
  setTimeout(function() {
    document.body.removeChild(iframe);
    // 앱이 설치되어 있다면 앱 실행
    window.location.href = appURL;
  }, 2000);
  
  // 앱이 설치되어 있지 않다면 앱스토어 다운로드 페이지로 이동
  setTimeout(function() {
    window.location.href = appStoreURL;
  }, 4000);
}
위 코드에서는 `yourappname://`이라는 URL Scheme을 이용하여 앱이 설치되어 있는지를 확인합니다. 
만약 앱이 설치되어 있다면 해당 URL Scheme을 가진 앱을 실행하게 됩니다. 
반면, 앱이 설치되어 있지 않다면 `https://itunes.apple.com/app/yourappname/id1234567890`와 같은 
링크를 이용하여 앱스토어 다운로드 페이지로 이동시킵니다. 
이 때, `window.location.href`를 변경하여 앱스토어 페이지로 이동합니다.



//
// 방법 3 : 'canOpenURL'메소드를 사용하는 방법
//

만약 위 방법 1의 코드를 사용하면서 iframe을 사용하는 것이 보안 문제로 인해 불가능하다면, 
iOS 9부터는 `canOpenURL` 메소드를 사용하여 URL Scheme이 실행 가능한지 확인할 수 있습니다. 
이를 사용하여 `openAppOrStore()` 함수를 다음과 같이 변경할 수 있습니다.

function openAppOrStore() {
  var appURL = "yourappname://";
  var appStoreURL = "https://itunes.apple.com/app/yourappname/id1234567890";
  
  // 앱이 설치되어 있는지 확인
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {
    if (xhr.readyState === 4 && xhr.status === 200) {
      // 앱이 설치되어 있다면 앱 실행
      window.location.href = appURL;
    }
  };
  xhr.open("GET", appURL, true);
  xhr.send();
  
  // 앱이 설치되어 있지 않다면 앱스토어 다운로드 페이지로 이동
  setTimeout(function() {
    window.location.href = appStoreURL;
  }, 4000);
}
위 코드에서는 XMLHttpRequest를 사용하여 URL Scheme이 실행 가능한지를 확인합니다. 
이 때, `open` 메소드의 `async` 파라미터를 true로 설정하여 비동기 요청을 수행하게 됩니다. 
요청이 완료되면 `readyState`가 4이고, `status`가 200인 경우에는 
앱이 설치되어 있다는 것을 의미하기 때문에 앱을 실행합니다. 
그렇지 않은 경우에는 앱스토어 페이지로 이동합니다.


스마트폰 BTC 채굴앱
https://get.cryptobrowser.site/34473645

 

Earn coins while browsing the web

Earn bitcoins while watching videos, chatting, or playing online. It has never been so easy to increase your income! Tell your friends about CryptoTab Browser, invite them to join, and earn more together. Grow your network—get more profit!

get.cryptobrowser.site


2021.03.16 - [iOS/Tips] - Universal Link (1/4) - 네이티브 환경설정
2021.03.16 - [iOS/Tips] - Universal Link (2/4) - 네이티브 링크 수신
2021.03.16 - [iOS/Tips] - Universal Link (3/4) - 웹서버 환경 설정
2021.03.16 - [iOS/Tips] - Universal Link (4/4) - 웹서버 환경 검증
2020/12/10 - [iOS/Tips] - Fat Static Library 빌드 (2/2)
2020/12/10 - [iOS/Tips] - Fat Static Library 빌드 (1/2)
2020/12/10 - [iOS/Tips] - Custom UserAgent 설정
2020/12/10 - [iOS/Tips] - CocoaPods 설치 및 제거
2020/12/10 - [iOS/Tips] - Clang diagnostic 경고 무시하기
2020/12/10 - [개발노트] - Bluetooth UUID
2020/12/08 - [개발노트] - 모바일 앱 메모리덤프 이슈 해결방법
2020/12/08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동
2020/08/21 - [Android/Tips] - aab파일 apk파일로 변환
2020/08/11 - [iOS/Swift] - WKWebView 화면 출력 완료 이벤트
2020/08/06 - [iOS/Tips] - 개발관련 폴더 경로
2020/07/19 - [Android/Tips] - 안드로이드 원격 디버깅 방법
2020/07/18 - [Android/Tips] - Cannot convert string value 'JETPACK_COMPOSE' to an enum value of type 'com.android.builder.model.AndroidGradlePluginProjectFlags$BooleanFlag' (valid case insensitive values: APPLICATION_R_CLASS_CONSTANT_IDS, TEST_R_CLASS_CONSTANT_IDS, TRANSITIVE_R_CLASS)
2020/07/18 - [Android/Tips] - OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2020/07/17 - [iOS/Tips] - 웹에서 iOS 앱 설치여부 체크

반응형

'개발 > Note' 카테고리의 다른 글

Bluetooth UUID  (0) 2020.12.10
모바일 앱 메모리덤프 이슈 해결방법  (0) 2020.12.08
Luhn 알고리즘  (0) 2020.06.02
NFC Xcode 설정  (0) 2020.05.29
NFC (Near Field Communication)  (0) 2020.05.29
블로그 이미지

SKY STORY

,