반응형

How to Implement Deep Linking in Flutter?

Flutter에서 딥링킹을 구현하는 방법은 무엇입니까?

https://medium.com/@dudhatkirtan/how-to-implement-deep-linking-in-flutter-f882b6d834da

 

How to Implement Deep Linking in Flutter?

Overview

medium.com

Overview

Deeplink in Flutter means the ability to open a specific page or perform a specific action within your app by clicking on a link from another app or a web page. It allows users to navigate to specific pages or sections of your app like cart, orders, or any product information, etc. Deeplink in Flutter is a very good feature for all developers and users. Flutter supports deep linking on iOS, Android, and web browsers. Implementing deep linking in Flutter apps enhances the user experience and makes it easier for users to navigate directly to specific sections.

Introduction

Deep linking is a crucial feature in mobile app development that enables smooth navigation to specific sections of different apps. This is very useful for users to access relevant content or perform specific tasks without manually navigating through the app’s screens. This deep linking feature eliminates the need for users to search for or manually locate the desired information within the app. Deep linking is a useful functionality for apps like e-commerce apps, content-driven apps, and social media platforms. By using deep links in Flutter, we can connect with other apps and services making it a good digital ecosystem.

Understanding Deep Links in Flutter

DeepLinks in Flutter means you have URLs or URIs to navigate or perform specific actions within a Flutter app. It directly helps users to access specific screens or content like webpages, screens, and notifications.

There are some concepts and terms that should be known to developers for using deep links in the Flutter applications.

  • URL Scheme -
  • A URL scheme is a unique identifier that identifies your app and allows it to handle specific deep links. It is generally a link to view or see a particular product in an e-commerce app.

Universal Links (iOS) and App Links (Android):

  • These are platform-specific mechanisms that help deep linking to work smoothly between web content and apps. These help in directly opening the content of the app, if the app is installed on the device, or fall back to the web page if the app is not present.

Deep Link Handling :

  • We need to handle the logic for deep lonks in Flutter like capturing the link URL and getting important data such as parameters or query strings. This captured information helps in navigating to a particular screen or performing the actions.

Implement Deep Linking on Android

To use deep links in your Flutter applications, we must have links for redirection that can be instantiated by adding intent filters for the incoming links.

In Android, we have two types of Uni Links, which are approximately the same as the meaning.

Open the DynamicLink section in firebase

  • On a domain that you may customize by adding your own name, company name, trademark, etc., dynamic links are generated. More relevant links that have been customized appear. After displaying this window, click Finish.
  • Now, on the newly opened page, select the “New Dynamic link” button.
  • Click on the new dynamic link button.

App Links -

App Links are the same as deep links, but it does require a specified host, i.e. a hosted file and along with this, the app links only tend to work with the HTTPS scheme.

You need to add the following code to your AndroidManifest file for adding deep links in Flutter. There you have to define an intent-filter and you can change the host with your need.


<!-- This is for App Links -->

<meta-data
            android:name="flutter_deeplinking_enabled"
            android:value="true" />

      <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with https://YOUR_HOST -->
        <data
          android:scheme="http"
          android:host="deeplink.example.com" />
            <data android:scheme="https" />
      </intent-filter>

Deep Links -

Deep links are the links in Android, which don’t require a specified host or any other custom scheme.

As discussed above, we have to paste for Deep links and we can change the host and scheme accordingly.



<!--  This is for Deep Links --> 
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> 
<category android:name="android.intent.category.BROWSABLE" /> 
<!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST --> 
<data android:scheme="blog" android:host="deeplink.example" /> 
</intent-filter>

We can use any of the intent filters in the AndroidManifest.xml file.

The intent filter is a statement in the manifest file that specifies what intent or component will be received on the app side, according to native app implementation. When an action occurs, it can specify additional actions that should be taken on this intent filter.

Data is what the URI format, which primarily resolves to the activity, represents. Also, a data tag must have the android attribute.

A category is mainly the type of intent-filter category. We have defined BROWSABLE in the category, which means that the intent filter can be accessed from the browser, and if not added, it will not be browsed.

Implement Deep Linking on iOS

In iOS also, we have two types of links-

Universal Links :

Universal links are those links that require a specified host or a custom scheme in their app. It works only with the HTTPS scheme. Below is the defined example of a universal link.

For setting up Universal Links we need to follow some steps-

  • Enable Associated Domains in your app’s entitlements.
  • Set up a unique URL identifier for your app.
  • Set up a JSON file on your website that contains information about your app’s URL identifier.

Enable Associated Domains

Creating the entitlements file in Xcode:

  • Open up Xcode by double-clicking on your ios/Runner.xcworkspace file.
  • Go to the Project navigator (Cmd+1) and select the Runner root item at the very top.
  • Select the Runner target and then the Signing & Capabilities tab.
  • Click the + Capability (plus) button to add a new capability.
  • Type “associated domains” and select the item.
  • Double-click the first item in the Domains list and change it from webcredentials.com to: applinks: + your host (ex: my-blogs.com). A file called Runner.entitlements will be created and added to the project.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- ... other keys -->
<key>com.apple.developer.associated-domains</key>
<array>
  <string>applinks:[YOUR_HOST_HERE]</string>
</array>
<!-- ... other keys -->
</dict>
</plist>

Custom URL:

In Custom URL, we don’t need a host or a custom scheme for our iOS app. An example of a custom URL is defined below. We need to add the host and scheme in the ios/Runner/Info.plist file.


<key>FlutterDeepLinkingEnabled</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
  <dict>
  <key>CFBundleTypeRole</key>
  <string>Editor</string>
  <key>CFBundleURLName</key>
  <string>flutterbooksample.com</string>
  <key>CFBundleURLSchemes</key>
  <array>
  <string>customscheme</string>
  </array>
  </dict>
</array>

Handling Deep Linking in the App

There are two ways your app will receive a link — from a cold start and brought from the background.

ATTENTION -

getInitialLink/getInitialUri should be handled ONLY ONCE in your app’s lifetime, since it is not meant to change throughout your app’s life

Once we are done with the Universal Links set up for our app, we will need to handle the links within our Flutter app. To do this, we need to use the uni_links package. Add this dependency in pubspec.yaml file and pub get it.

uni_links: ^0.5.1

Now, we just need to register a callback to handle incoming deep links.

import 'package:uni_links/uni_links.dart';

void main() {
   // Initialize the deep link handler
   initUniLinks();
   runApp(MyApp());
}

void initUniLinks() async {
   // Ensure that the app is ready to handle deep links
   await getInitialUri();

   // Set up a stream subscription to handle deep links when the app is running
   uriSubscription = uriLinkStream.listen((Uri uri) {
      // Handle the deep link here
      handleDeepLink(uri);
   });
}

void handleDeepLink(Uri uri) {
   // Process the deep link URI and navigate accordingly
   // You can extract parameters or perform specific actions based on the deep link data
}

Advanced Usage

Some additional features enhance the capabilities of deep linking in our Flutter app. These features help in creating more personalized and smooth user experiences, tracking user engagement, optimizing marketing efforts, and improving overall app performance.

Deep Link Analytics -

By implementing Deep Link Analytics, we can track and analyze user engagement with deep links. We can get the data on the number of clicks, conversions, and user behavior after accessing the app through a deep link. With this information, we can get to know about our deep links and can do some optimization if needed.

Deferred Deep Linking -

This helps in handling the scenarios, where the app is not installed on the user’s device on clicking the deep link. In these cases, the user is redirected to the app store to download the app and after installation, the app can open and handle the deep link that triggered the installation.

Dynamic Deep Links -

These help in generating deep links programmatically with dynamic parameters. It means we can generate deep links that include user-specific data, product IDs, or other variables.

Deep Link Attribution -

By using this you can track the source of each deep link and can know which channels are getting more engagement and conversions.

Deferred App Deep Linking -

Some platforms handle deep links when the app is already installed but not in the foreground. But this feature works even if the app is in the background or not currently running.

Example App

Let us understand this through a code. In the AndroidManifest.xml file, I have declared my link like — blog://deeplink.example

We will declare the function main.dart file like this.

import 'package:blog/home.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:uni_links/uni_links.dart';
import 'package:flutter/services.dart' show PlatformException;

void main() {
  initUniLinks();
  runApp(MyApp());

 initUniLinks()async{
  try{
    Uri? initialLink = await getInitialUri();
    print(initialLink);
  } on PlatformException {
    print('platfrom exception unilink');
  }
}
}


class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context){
    return MaterialApp(
      home: HomeScreen(),
    );
  }
}

There is some page that says it as HomeScreen.

import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({Key? key}) : super(key: key);

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {

    return const Scaffold(
      body: Center(
        child: Text("Home Screen"),
      ),
    );
  }
}

We will open this app through the deeplink shown below. We will paste the same link(blog://deeplink.example) in the browser and it will show us the APP NAME of that app and will navigate us to the app by clicking on continue

Conclusion

  1. Deep links help in seamless navigation to specific screens from external sources like the web, notifications, etc.
  2. By using deep links, users are more engaged and satisfied. This also helps users to users to access relevant and personalized content.
  3. Deep links provide cross-platform compatibility like for both iOS and Android.
  4. Deep links can be customized with parameters or query strings, allowing for dynamic and personalized experiences based on user-specific data.
  5. We can test and analyze deep links, also we can track user behavior, and optimize our app’s deep linking strategy.
  6. By using deep links in Flutter, we can interact with other apps, services, or platforms. Also, we can collaborate and share the data.
반응형
반응형

딥링크(Deeplink) : URI스킴, 유니버셜 링크, 앱링크 구분과 이해

딥링크 (Deeplink)

http 혹은 https 로 시작하는 인터넷 주소는 모두 특정 서비스의 웹페이지로 이동합니다.

https://igaworks.com 을 주소창에 입력하면 IGAWorks 홈페이지로 이동합니다.
https://adbrix.io 를 주소창에 입력하면 애드브릭스 홈페이지로 이동합니다.

모바일 앱에서도 이와 유사한 기능을 하는 것이 있습니다.
바로 딥링크(Deeplink) 입니다.

딥링크는 특정 주소 혹은 값을 입력하면 앱이 실행되거나 앱 내 특정 화면으로 이동시키는 기능을 수행합니다.
즉, 딥링크가 사용되면 광고에 반응한 이용자는 앱이 바로 실행되어 특정 화면으로 이동하는 경험을 하게 됩니다. 혹은 앱 설치 후 실행하면 특정 화면으로 바로 이동하게 됩니다(지연된 딥링크). 따라서 광고를 운영하는 마케터 입장에서는 광고 성과 최적화를 위해 반드시 활용해야 하는 기능입니다.

딥링크는 3가지 방식으로 구분됩니다.

  • URI 스킴 방식 : 앱에 URI 스킴(scheme) 값을 등록하여 딥링크 사용
  • 앱링크(App Link) : Android 제공 - 도메인 주소를 이용한 딥링크 사용
  • 유니버셜 링크 (Universal Link) : iOS 제공  - 도메인 주소를 이용한 딥링크 사용

모두 딥링크 기능을 수행 함에도 왜 'URI 스킴', '앱링크', '유니버셜 링크' 방식으로 각각 구분하는 것일까요?
각각의 기능과 차이점에 대해서 알아보겠습니다.

'URI Scheme' 방식의 딥링크

'URI Scheme' 방식 이해

가장 일반적으로 사용되는 딥링크 방식은 URI Scheme(URI 스킴) 방식 입니다.

URI 스킴을 이용한 딥링크는 앱에 Scheme값을 등록하는 형태로 앱을 구분합니다. 스킴은 앱마다 등록할 수 있는 값으로 "특정 스킴값을 호출하면 특정 앱이 오픈된다." 라는 약속을 실행합니다. 여러분이 트위터 앱을 오픈하고자 한다면 twitter:// 라는 스킴값을 이용하면 됩니다. 이 스킴값은 앱 개발시 효율적인 앱 오픈을 위해 자체적으로 개발사에서 자신들만의 값으로 등록을 하게 됩니다.

앱 내에서의 특정 페이지는 'path' 값으로 구분합니다. 예를 들어, 트위터 앱의 회원가입 페이지를 오픈하고자 한다면 twitter://signup 이라는 값을 사용합니다.

정리하면, URI 스킴 방식은 Scheme://Path라는 두개의 요소로 구성됩니다.

  • Scheme://Path
  • Scheme = 앱을 특정함 (트위터)
  • Path = 앱 내 페이지를 특정함 (트위터 내 회원가입 페이지)

안드로이드의 경우 아래와 같이 Androidmanifest.xml 이라는 파일에 스킴값을 등록합니다.

[위 스크린샷에서 android:scheme 라고 적힌 항목이 스킴값입니다.]

iOS 의 경우 앱 정보 화면에서 URL Scheme 항목에 스킴값을 입력할 수 있습니다. 

[iOS 에서 스킴값을 등록하는 화면]


URI 스킴 방식의 한계

URI 스킴 방식의 딥링크는 앱의 수가 상대적으로 적었던 시기에는 광고를 통해 앱을 바로 실행시키는 훌륭한 마케팅 수단이었습니다. 그러나 앱 수가 증가하면서 생각하지 못한 문제가 발생하기 시작하였습니다.  바로 앱 스킴값이 서로 중복되는 경우에 대한 문제입니다. 앱 개발자 입장에서는 앱에 등록된 스킴값이 자신들의 앱만 사용하는 고유값인지 확인할 방법이 현재는 없습니다.

구글플레이 앱은 자신들의 앱을 오픈하기 위한 스킴 값으로 market:// 란 값을 사용하고 있습니다. OneStore, 삼성 앱스토어 등의 오픈 마켓 또한 이 스킴 값을 사용합니다. 따라서 안드로이드 이용자들은 아래처럼 어떤 앱을 실행시켜야 하는지에 선택하는 화면을 보게 됩니다.

[서로 동일한 market:// 스킴값을 사용할 경우 발생하는 문제.]

즉, 안드로이드 시스템이 현재 market:// 란 스킴값으로 앱을 열려고 할 때 사용자에게 " 이 3종의 앱이 모두 "market://" 란 스킴값을 사용하는데 어떤 앱을 열어야 하나요?" 라고 물어보는 화면입니다. 안드로이드, iOS 모두 이와 비슷한 문제를 가지고 있습니다. 앱을 개발하는 개발자가 자신이 적용한 스킴값이 다른앱은 사용하지 않는 고유값인지 아닌지 확인할 수 있는 방법이 없고 다른 앱이 자신의 스킴값을 사용한다 할지라도 이를 방지할 방법이 없는 상황입니다.

애플과 구글의 개발자들은 이를 근본적으로 막을 수 있는 방법은 없을지 고민했습니다. 그 고민끝에 탄생한 것이 유니버셜 링크 (iOS 제공)와 앱링크 (Android 제공) 입니다.
  

유니버셜 링크와 앱링크

웹페이지 주소를 사용한 딥링크

현재 여러분이 사용하고 있는 사이트의 인터넷 주소는 모두 고유의 값을 가지고 있습니다. 가령 아이지에이웍스는 igaworks.com 이라는 고유의 인터넷 주소를 가지고 있고 애드브릭스 역시 adbrix.io 라는 고유의 주소를 가지고 있습니다. 이를 도메인 (Domain) 주소라고 합니다.

애플과 구글의 개발자들은 이 도메인 주소를 딥링크 실행값으로 사용하기로 결정합니다.  예를 들면, 스마트폰 브라우저 앱 주소창에 http://naver.com 을 입력하면 네이버 앱이 바로 오픈되어 사용할 수 있도록 한 것입니다.

바로 이 기능을 iOS 에서는 유니버셜 링크(Universal Link), Android 에서는 앱링크(App Link)라고 부릅니다.

참고자료 (1) : [Add Android App Links]
참고자료 (2) : [Universal Links for Developers]

안드로이드의 경우 Androidmanifest.xml 라는 파일에서 아래와 같이 앱링크 도메인을 등록할 수 있습니다.
(아래 예시는 애드브릭스 트랙킹 링크의 유니버셜 링크, 앱링크 연동을 기준으로 작성하였습니다.)

 
iOS 의 경우 Singing & Capabilities 에서 Associated Domains 에서 등록할 수 있습니다.

 

유니버셜 링크와 앱링크의 한계

하지만 안타깝게도 유니버셜 링크와 앱링크가 아직까지는 완전하지 않습니다. 모든 앱에서 유니버셜 링크와 앱링크 오픈을 지원하는 것이 아니기 때문입니다.

앱링크는 구글에서 만든 앱에서만 동작하고, 구글 이외에 앱에서는 정상적으로 동작하지 않습니다. 유니버셜 링크 역시 애플에서 만든 앱 이외에는 정상적으로 동작하지 않습니다.

애드브릭스 팀에서는 주요 환경 별 유니버셜 링크, 앱링크 실행 결과를 확인했습니다.
결과를 보면 하나의 방식이 모든 환경에 완벽하게 대응하지 못하고 있습니다. 따라서 원활한 광고 운영과 어트리뷰션을 위해서는 URI스킴 방식, 유니버셜 링크, 앱링크 모두 연동이 필요하다는 결론에 도달합니다.

 

앱링크 테스트 결과

 테스트 환경테스트 결과

1 안드로이드 카메라 앱에서 QR 코드 촬영하여 앱 실행 앱링크 작동
2 Gmail 앱에서 링크를 클릭하여 앱 실행 앱링크 작동
3 카카오톡에서 링크를 클릭하여 앱 실행 URI스킴 방식 작동
4 네이버 앱에서 주소창에 링크 입력 후 앱 실행 URI스킴 방식 작동
5 네이버 앱에서 카메라로 QR 코드 촬영하여 앱 실행 URI스킴 방식 작동
6 크롬에서 주소창에 트래킹 링크 입력 후 앱 실행 딥링크가 동작하지 않음
7 크롬에서 링크를 클릭하여 앱 실행 앱링크 작동
8 삼성 브라우저에서 주소창에 링크 입력 후 앱 실행 딥링크가 동작하지 않음
9 삼성 브라우저에서 링크를 클릭하여 앱 실행 앱링크 작동

 

유니버셜 링크 테스트 결과

 테스트 환경테스트 결과

  사파리 브라우저 주소창에 링크 입력 후 앱 실행 URI스킴 방식 작동
(경우에 따라 유니버셜 링크 작동)
2 사파리 브라우저에서 링크를 클릭하여 앱 실행 URI스킴 방식 작동
3 아이폰 카메라 앱으로 QA 코드 촬영하여 앱 실행 유니버셜 링크 작동
4 아이폰 이메일 앱에서 링크를 클릭하여 앱 실행 유니버셜 링크 작동
5 Gmail 앱에서 링크를 클릭하여 앱 실행 URI스킴 방식 작동
6 카카오톡에서 링크를 클릭하여 앱 실행 URI스킴 방식 작동
7 네이버 앱에서 주소창에 링크 입력 후 앱 실행 URI스킴 방식 작동
8 네이버 앱에서 카메라로 QR 코드 촬영 후 앱 실행 URI스킴 방식 작동
9 크롬 주소창에 링크 입력 후 앱 실행 URI스킴 방식 작동
10 크롬에서 링크를 클릭하여 앱 앱 실행 URI스킴 방식 작동

 

딥링크, 더 알아두기

앱에 딥링크 적용하기

애드브릭스는 앱에 설정된 딥링크 설정값을 받아 실행하는 역할을 수행할 뿐, 딥링크 그 자체는 앱 내에 먼저 설정이 되어있어야 합니다. 즉, 앱 내에 자체적으로 딥링크 설정이 완료 되어야만 딥링크 기능을 이용할 수 있습니다. 문을 열기 위한 열쇠는 광고주 앱이 직접 만들어야 하고, 그 열쇠를 받아서 문을 여는 역할만 애드브릭스가 수행한다고 생각하면 이해하기 쉽습니다.

따라서 마케터가 딥링크를 사용하고자 한다면, 앱 개발팀을 통해 딥링크 사용에 필요한 설정값(스킴과 패스값, url값)을 확보한 후 트래킹링크 설정 옵션에 입력해야 합니다. (Ad-Landing 세팅, 트래킹링크 발급)

지연된 딥링크

지연된 딥링크(Deferred Deep Link) 란 마켓에 랜딩되어 앱 설치 후 실행한 이용자가 앱 첫 화면이 아닌, 지정된 특정 앱 페이지로 이동되는 기능을 의미합니다. 예를 들어, 'A운동화 광고' 트래킹링크가 적용된 광고에 참여한 이용자가 마켓으로 이동하여 앱을 설치하고 실행하면 'A운동화' 상품 페이지로 바로 이동합니다.
 

애드브릭스 All-Link : URI스킴, 앱링크, 유니버셜 링크 모두 사용하기

앞서 살펴본 것 처럼 URI스킴, 유니버셜 링크, 앱링크 중 하나의 딥링크 방식 만으로는 모든 환경에 대응하지 못합니다.
따라서 광고UX 최적화를 위해서는 3개 방법을 모두 적용하여 상호보완적으로 사용하는것이 최선의 방법입니다.

애드브릭스의 트래킹 링크는 URI스킴, 유니버셜 링크, 앱링크를 하나의 링크로 지원하는 All-Link 기능을 제공합니다. 애드브릭스 트랙킹 링크의 도메인을 이용하여 유니버셜 링크, 앱링크를 만들수 있습니다. 유니버셜 링크와 앱링크를 지원하지 않는 앱에서도 정상적으로 어트리뷰션이 될 수 있도록 URI스킴 방식 동작 또한 지원합니다. 즉, 유니버셜 링크와 앱링크가 작동되지 않는 환경에서는 2순위로 URI스킴 방식을 작동시켜 앱 실행과 목적된 화면 이동이 정상적으로 완료될 수 있도록 지원합니다.

자세한 내용은 아래 연동 가이드에서 확인하실 수 있습니다.

참고자료 : [Android 앱링크 연동하기]
참고자료 : [iOS 유니버셜 링크 연동하기]   

 

 


URI   Uniform Resource Identifier   인터넷 식별자

http://www.ktword.co.kr/test/view/view.php?m_temp1=2340 

1. URI (Uniform Resource Identifier)
  
  ㅇ 인터넷 서비스(웹 서비스 등)를 전제로 하여,
     - 인터넷 응용 정보자원(텍스트,비디오,음향,이미지,기타 서비스 등)에 대한
       통일적 식별체계를 지칭하는 개념적 용어

  ㅇ 표준 : RFC 3986 : "Uniform Resource Identifier (URI): Generic Syntax"
     - (2732, 2396, 1808들의 대체)


2. URI 하위 종류

  ※ URI는 이 모든 것들을 총칭하는 용어

  ㅇ URL (Uniform Resource Locator) : 특정 자원이 있는 장소에 대한 경로(주소)
     - 인터넷 콘텐츠에 대한 프로토콜/서비스/접근방법/경로 등 자원의 위치를 나타냄
        . 지리적 위치에 무관하게 특정 호스트 내 자원의 위치를 지칭함

  ㅇ URN (Uniform Resource Name) : 특정 자원에 대한 이름 그 자체
     - 인터넷 도메인명과는 독립적으로 특정 콘텐츠에 대한 고유 식별(ID)
        . 例) 특정 이름, 네임스페이스, 도서번호인 ISBN 등

  ㅇ URC (Uniform Resource Charcteristic) : 특정 자원에 대한 특성 정보
     - 특정 콘텐츠의 저자,제목 등의 특성 정보


3. URI 또는 URL 구문

  ㅇ 구문 => URI스킴://사용자이름:암호@호스트명:포트번호/경로?쿼리#URI프래그먼트
     - 참고적으로, 
        . `콜론(:)`은 2개를 묶은 쌍(pair)에서 좌우 구분을 위한 구분자 임
        . `대쉬(//)`는 어떤 시작을 알리는 것
        . 원칙적으로 URI 길이 제한 없으나, 구현상 2천자 등의 상한선은 있음

  ㅇ URI Scheme (스킴)
     - 접근 프로토콜을 가리킴
        . URI 표기에서, URI 시작부터 콜론(:) 직전까지의 표현
     - 例)
        . HTTP   => http://www.ktword.co.kr
        . HTTPS  => https://www.example.com
        . FTP    => ftp://file.fileserver.com/entries/01
        . 이메일 => mailto:사용자이름@호스트명?Subject=Feedback
        . SIP    => sip:사용자이름:암호@호스트명;uri-parameters 
        . 전화   => tel:1234;phone-context=servername.example.com

     * URI 스킴 목록 ☞ IANA 공식 URI Schemes

  ㅇ 호스트명(Hostname)
     - 인터넷 상에서 유일(唯一)한 식별
     - 여기서, 호스트명은, FQDN 또는 IP 주소 형태 모두 가능
     - 例) `www.ktword.co.kr`, `file.fileserver.com`, `192.168.xxx.xxx` 등

  ㅇ 경로(path)
     - 例) 위에서, 호스트명 직후에 있는 `/entries/01`


4. 절대 URI, 상대 URI, 기준 URI

  ㅇ 절대(Absolute) URI : 모든 전체 경로를 다 기술한 URI 표현 (길이가 매우 클 수 있음)
  ㅇ 상대(Relative) URI : 전체 경로 중 기준 URI로부터 상대적 경로 표현
  ㅇ 기준(Base) URI     : 보통, HTML 문서 내 `Head 요소` 안에 `Base 요소`에 표시


5. URI 변화방향

  ㅇ 단순히, 정적인 자원의 위치나 식별을 나타내는 수준에서,  
     - 점차적으로, 동적 자원이나 서비스 결합 등을 고려하며 확대 중

  ㅇ 문자체계의 변화 : (국제화)
     - 문자체계가 과거 US - ASCII코드에서, 유니코드(Unicode)를 적용하는 국제화된 URI로 확장하며,
     - 국제화된 표준인 IRI(Internationalized Resource Identifier) 도모
     - (URI %인코딩 방식 例) `나` => UTF-8 인코딩 `%EB%82%98` (동양권 문자 3 바이트)

URL   Uniform Resource Locator  

http://www.ktword.co.kr/test/view/view.php?m_temp1=867&id=1230 

 

URL

URL   Uniform Resource Locator   (2022-02-20)

www.ktword.co.kr

 

반응형
반응형

브라우저에서 모바일 애플리케이션 열기. 

Open Mobile Application From The Browser( web) , intent, deeplink, url scheme

https://vhudyma-blog.eu/open-mobile-application-from-the-browser/  

 

딥링킹 유형

딥 링크에는 두 가지 주요 유형이 있습니다.

  • 기본
  • 링크는 응용 프로그램이 설치되어 있으면 열리고 그렇지 않으면 오류 메시지가 표시됩니다.
  • 연기
  • 링크는 애플리케이션이 설치되어 있으면 열리고, 그렇지 않으면 사용자가 Play 또는 App Store(또는 선택한 다른 위치)로 리디렉션됩니다.

이 외에도 Contextual Deep Linking 에 대해 들어보셨을 것입니다 .

상황별 딥 링크는 일반적으로 사용자에 대한 추가 정보를 수집하기 위해 추가된 일부 추가 매개변수와 함께 기본이거나 지연됩니다.


 

웹 브라우저에서 앱 열기

 

URL Scheme

사용자를 앱의 특정 콘텐츠로 바로 연결하는 URL 이다.

ex) naversearchapp://

위와 같은 URL Scheme를 이용하면 브라우저에서 해당 Scheme를 읽고 그 Scheme에 해당하는 앱이 있는 경우 (앱에서 설정) 열어준다.

하지만 다음과 같은 한계가 있다.

  • naversearchapp 같이 앞에 붙는 스키마는 유니크한 값이 아니기 때문에 같은 이름이 있을 경우 어떤앱을 열지 물어보게된다.
  • 앱이 미설치되어있는 경우 동작하지 않는다.

Android

intent filter

https://developer.android.com/guide/components/intents-filters?hl=ko

이 intent filter의 역할은 앱 열기에 한정된 것이 아니고 특정 앱으로의 메시징을 처리하는 객체인데, 이걸 딥링크처럼 활용할 수 있다.

앱에서 intent관련 설정을 지정하고, 웹에서 intent:// 와 같이 실행하면 앱을 실행할 수 있다.

이 방법은 위 URL 스키마 방식의 한계를 없애준다.

패키지명을 이용하기 때문에 유니크하고, 앱이 미설치되어있는 경우 해당 패키지에 해당되는 playstore로 이동한다.

https://developer.android.com/training/app-links/verify-site-associations?hl=ko

위 인텐트 필터 방식을 활용하여 웹사이트 URL 기반으로 앱을 여는 방식 (android 6.0 이상지원)

예를들어 https://medium.com 를 방문하는 경우 해당하는 앱을 열 수 있다.

웹에서는 무엇을 해주어야 하나?

기본적으로 인텐트 필터 설정은 앱쪽에서 해주지만, 웹에서도 해줘야할 것이 있다.

앱링크를 제공할 도메인이 특정 앱과 매칭된다는 것을 알려주기 위해 앱쪽에서 생성하는 assetlinks.json  https://{도메인}/.well-known/assetlinks.json 에 제공해줘야한다.

여기에는 몇 가지 제약이 따르게 되는데,

  1. HTTPS만 지원한다.
  2. assetlinks.json 를 가져오는데에 있어서 리디렉션이 일어나지 않아야하고 application/json 타입으로 응답되어야한다.
  3. 서브도메인이 다른 경우 모두 assetlinks.json 제공이 필요하다. 예를들어 www.medium.com  m.medium.com 가 존재한다면, assetlinks.json 를 모두 제공해야한다.
  4. robot.txt 가 접근가능해야한다. 즉, VPN 등이 있어야 접근가능한 경우 적용 불가능하다.

테스트는 어떻게하지?

이부분이 제일 골치아팠는데, 위와 같은 제약사항이 있기 때문에 VPN을 사용하거나 사내망이 따로 있는 경우 테스트하기가 번거롭다.

예를들어, 개발환경인 dev.aa.com 가 있고, 실제환경인 aa.com 이 있다고 했을 때 위 제약사항이 있기 때문에 assetlinks.json을 두 환경을 제공하는 서버 각각 넣어줘야한다.

대부분에 개발환경 서버는 VPN 뒤에 있기 때문에 위 4번 제약사항에 걸리게 된다.

이 때 찾아보았던 해결할 수 있는 방법은

  1. 만약 dev.aa.com  aa.com 과 같이 서브도메인 / 루트도메인의 관계라면 루트도메인에 assetlinks를 *.aa.com 과같이 설정함으로써 적용이 가능하다.
  2. app.dev.aa.com 과 같은 서버를 실제환경에 열어두고 여기서 테스트를 진행한다.

앱이 설치되어있지 않은 경우는?

기본적으로 앱링크 / 유니버셜링크는 앱이 설치되어있지 않은 경우 단순히 웹에서 해당 url을 표시하게 된다. 이런 경우 보통 "앱으로 이동" 과 같은 버튼을 표시하고, 클릭시 위에서 말한 인텐트 필터를 사용하게 된다.

iOS

ios의 경우 deffered deep link나 intent 필터 등의 기법은 없고 universal 링크만 이용 가능하다. (ios 9 이상)

https://developer.apple.com/ios/universal-links/

기본적으로 app link와 동일하다. 웹사이트 URL 기반으로 앱을 열게 동작해준다.

웹에서는 무엇을 해주어야 하나?

안드로이드와 마찬가지로 .well-known 하위에 파일 추가가 필요하다. (다른점은 루트 디렉토리에 넣어도 무방)

앱쪽에서 생성한 apple-app-site-association 파일을 넣어주게되는데, 마찬가지로 application/json 타입 제공이 필요하다.

주의할 점은, 안드로이드의 경우 assetlinks.json 의 파일 포맷이 json 이라 브라우저가 알아서 json 으로 처리해주는 반면, 해당 파일은 파일 포맷이 없으므로, 명시적으로 제공이 필요하다.

기본적인 제약사항 (VPN X, redirect X, 서브도메인지원 X)은 앱링크와 동일하다.

따로 문서에 명시되어있지는 않은데, 테스트 결과 앱링크와 마찬가지로 앱쪽에서 *.루트도메인 과 같이 설정한 경우 루트도메인에 넣은 설정파일로 서브도메인 지원이 가능하다.

앱이 설치되어있지 않은 경우는?

마찬가지로 앱열기버튼을 제공할 수 있다. (특히 유니버셜링크는 safari의 경우 앱열기버튼을 네이티브에서 제공하고 있다)

다만, iOS에서는 인텐트 필터처럼 앱의 설치여부를 구분해서 동작할 수 없기 때문에 조금 추가작업이 필요하다.

다음과 같은 방법을 고려할 수 있다.

  • firebase 다이나믹링크, 브랜치 등 외부 서비스를 이용하는 방식 (ex ) Medium, reddit )
    • 위 서비스들이 앱 설치/미설치시 분기처리를 제공해준다. Android의 경우 내부적으로 인텐트 필터를 이용하는 것으로 보인다.
  • 직접 처리하는 방식
    • 라우트를 https://aa.com/launchApp 과 같이 지정해놓고, 해당 라우트로 리디렉션 시킨다.
    • 만약 앱이 설치되어 있다면 유니버셜링크를 통해 서버에 접근하지않고 바로 앱이 열릴테고, 앱이 설치되어있지 않다면 해당 라우트로 들어오고 fe 서버에서 app store로 리디렉션 시킬 수 있다.

 

* https://godsenal.com/posts/%EC%9B%B9-%EB%B8%8C%EB%9D%BC%EC%9A%B0%EC%A0%80%EC%97%90%EC%84%9C-%EC%95%B1-%EC%97%B4%EA%B8%B0/

반응형

+ Recent posts