반응형

유니버셜링크 적용 시 도메인 루트에 AASA(apple-app-site-association)파일을 생성하여
관련정보를 설정해야 한다. 개발 중에 주의할 점은 이 파일을 다운받게 되면 캐싱되어
그 이후 계속적으로 캐싱된 파일이 사용되므로 중간에 내용을 바꾸어도 적용되지 않는다.
이 상황을 모르고 작업하다보면 원인파악에 많은 시간을 낭비할 수 있으므로 다음 내용을 숙지하기 바란다.

AASA파일을 다운받아 캐싱되는 경우
1. 앱 최초 설치 시 AASA파일 인스톨할 경우 (앱스토어 다운로드)
2. 앱 스토어 업데이트로 인한 인스톨 (앱 업데이트)

위 두가지 이외는 더 이상 다운로드 되지 않을 수 있으므로 중간에 해당 파일을 수정했을 경우
정상동작하지 않고 이전 파일(캐싱된 파일)로 적용된다.
또한 AASA파일을 다운로드가 안될경우(방화벽 또는 도메인 문제 등.) 역시 정상 동작되지 않으므로
해당 파일 다운로드가 가능한지 체크한다.
개발중 AASA파일 갱신으로 인하여 캐싱된 파일을 강제 업데이트 할 경우 다음과정을 통해 업데이트하길 바란다.

1. 디바이스에서 앱 제거
2. 디바이스 재시작
3. 앱 재설치
4. 1~3번을 2~3번 재시도
5. 앱 내에서 AASA파일이 다운로드 성공인지 확인.

AASA 파일 다운로드 성공 확인 방법 :
- 휴대폰의 노트앱 실행
- 링크를 노트에 붙여넣기
- 해당 링크를 2초이상 누르고 있으면 드롭 다운 메뉴가 뜨는데 
  메뉴리스트에 '링크 열기' 표시되지 않고 '[앱이름] 으로 열기'가 
  표시되면 성공이다.
  
  ex) AASA 파일 링크
  https://myapp.page.link/apple-app-site-association

  ex) AASA 파일 내용 
  {"applinks":{"apps":[],"details":[{"appID":"ABCDEF2TH3.com.company.myapp","paths":["NOT /_/*","/*"]}]}}



반응형

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

UIScrollView 스크린샷 만들기  (0) 2022.10.24
문자열 숫자에 콤마 넣기  (0) 2022.10.14
웹 저장 데이터 (Cookie, Cache) 삭제  (0) 2021.09.24
버전분기 샘플  (0) 2021.08.02
시뮬레이터 분기  (0) 2021.08.02
블로그 이미지

SKY STORY

,
반응형
  • 이제 기본적인 설정 및 테스트를 완료하였으므로 구현 코드를 보자
// 수신되는 링크 포맷
// com.company.appname://google/link/?deep_link_id=https://com.company.appname/testlink?param=XXXXXX ... &match_message=Link is uniquely matched for this device.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
    {
        self.handleIncomingDynamicLink(dynamicLink)
        return true
    }

    return true
}

// 수신되는 링크 포맷
// https://appname.page.link/?link=https://com.company.appname/testlink?param=XXXXXX ...
func application(_ application: UIApplication,
                   continue userActivity: NSUserActivity,
                   restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
{
    if let incomingURL = userActivity.webpageURL {
        print("Incoming : \(incomingURL)")
 		
        let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
            guard error == nil else {
                print("Found an error! \(error!.localizedDescription)")
                return
            }
            if let dynamicLink = dynamicLink {
                self.handleIncomingDynamicLink(dynamicLink)
            }
        }

        if linkHandled
        {
            return true
        }
        else
        {
            if incomingURL.host == "appname.page.link" {
                guard let components = URLComponents(url: incomingURL, resolvingAgainstBaseURL: true),
                      let queryItems = components.queryItems else { return false }
                if let link = queryItems.first(where: { $0.name == "link" })?.value {
                    print("link = \(link)")
					// https://com.company.appname/testlink?param%3D12 ...
                    return true
                }
            }
        }
    }

    return false
}

// 수신되는 링크 포맷 
// https://com.company.appname/testlink?param=@#$%@#$%^#$%^
func handleIncomingDynamicLink(_ dynamicLink: DynamicLink) {
    guard let url = dynamicLink.url else {
        print("The dynamic link object has not url.")
        return
    }
    print("url : \(url.absoluteString)")

    guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
          let queryItems = components.queryItems else { return }
    if let param = queryItems.first(where: { $0.name == "param" })?.value {
        print("param = \(param)")
    }
}

 

  • 상황에 따라 호출되는 포맷이 다르므로 주의하도록 한다.

 

  • 앱이 설치되어 있고 웹링크를 통해 호출된 경우 :

https://appname.page.link/?link=https://com.company.appname/testlink?param=XXXXXX ...

 

  • 앱이 설치되어 있지 않아 스토어에서 설치된 후 실행된 경우 :

com.company.appname://google/link/?deep_link_id=https://com.company.appname/testlink?param=XXXXXX ... &match_message=Link is uniquely matched for this device.

 

 

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

2022.07.21 - [iOS/Tips] - 유니버셜 링크(Universal Links) 문제점 해결

 

 

반응형
블로그 이미지

SKY STORY

,
반응형

환경 설정이 정상적으로 되어있는지 확인하려면 아래 사이트에서 가능하다.

 

Apple Search API Validation Tool 

https://search.developer.apple.com/appsearch-validation-tool

ex) 도메인이 'www.youtube.com'일 경우 검증

※ 주의 사항 : 

☞ 유니버셜링크는 앱링크 도메인이 등록된 앱이 스토어에 반영되어 있어야 하며 최도 등록시 활성화 되는데 최대 48시간의 시간이 걸릴  있다. (대부분 바로 적용 됨.)

☞ 위의 검증 사이트는 참고용으로만 사용한다. 정상적으로 동작하지만 경고를 출력하기도 한다. 예를들어 youtube.com은 정상으로 출력되나 google.com의 경우 오류가 뜬다. (참고만 할 것!)

 

 

Branch

https://branch.io/resources/aasa-validator/

Branch 와 Firebase 다이나믹 링크 비교

https://blog.branch.io/ko/branch가-firebase-다이나믹-링크를-대체할까요/

 

Apps Flyer

https://www.appsflyer.com/tools/app-links-validator/

 

Universal Link Validator

https://limitless-sierra-4673.herokuapp.com

 

yURL: Universal Links / AASA File Validator

https://yurl.chayev.com

 

 

※ 주의 사항

마지막으로, 테스트 도중 AASA파일을 수정했을 경우 앱은 이미 해당 파일을 앱 로컬 영역에 다운받아 캐싱되고 있으므로 변경된 사항이 적용되지 않았을 경우 다음과 같이 시도해 본다.

앱 삭제, 사파리의 '방문 기록 및 웹 사이트 데이터 지우기', 재부팅, 다시 앱 설치  이렇게 3번 반복!

이후 변경내용이 적용 된다. 

 

 

 

 

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.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

 

 

 

 

반응형
블로그 이미지

SKY STORY

,
반응형

스마트폰 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

 

apple-app-site-association 파일 생성 및 작성

'appID' [App ID Prefix].[Bundle ID] 작성해 준다.

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "M1ACL7W8FR.com.example.myapp",
                "paths": [ "*" ]
            }
        ]
    }
}

 

해당 파일을 도메인 루트에 복사 한다.

해당 파일이 정상적으로 접근 가능한지 테스트해 본다.

ex) 웹 브라우저에서 등록된 도메인 URL로 접근했을 때 작성된 json 정보가 출력되는지 확인한다.

https://www.youtube.com/apple-app-site-association

 

※ 주의 사항 :

☞ App ID Prefix 부분은 Team ID로 잘 못 기입하지 않도록 주의 한다. 일반적으로 이 부분은 Team ID와 동일하지만 다른 경우도 있으니 반드시 App ID Prefix를 확인하고 사용하도록 한다.

위의 AASA파일 생성 시 반드시 큰 따옴표( " )를 사용해야 한다. 또한 파일의 확장자는 붙이지 않는다.

 

스마트폰 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.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

 

반응형
블로그 이미지

SKY STORY

,
반응형

iOS Deployment Target iOS 13이상 - Swift

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    ...
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let _ = (scene as? UIWindowScene) else { return }
        
        
        // Get URL components from the incoming user activity.
        guard let userActivity = connectionOptions.userActivities.first,
              userActivity.activityType == NSUserActivityTypeBrowsingWeb,
              let incomingURL = userActivity.webpageURL,
              let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
            return
        }
        print("url = \(incomingURL.absoluteString)")
        
        // Check for specific URL components that you need.
        guard let path = components.path,
              let params = components.queryItems else {
            return
        }
        print("path = \(path)")
        
        if let param = params.first(where: { $0.name == "param" })?.value {
            print("param = \(param)")
        } else {
            print("parsing error")
        }
    }
    ...
}

 

iOS Deployment Target iOS 13미만 - Swift

class AppDelegate: UIResponder, UIApplicationDelegate {
    ...
    func application(_ application: UIApplication,
                     continue userActivity: NSUserActivity,
                     restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
    {
        // Get URL components from the incoming user activity.
        guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
        let incomingURL = userActivity.webpageURL,
        let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
            return false
        }
        print("url = \(incomingURL.absoluteString)")
        
        // Check for specific URL components that you need.
        guard let path = components.path,
        let params = components.queryItems else {
            return false
        }
        print("path = \(path)")
        
        if let param = params.first(where: { $0.name == "param" })?.value {
            print("param = \(param)")
            return true
        } else {
            print("parsing error")
            return false
        }
    }
    ...
}

 

iOS Deployment Target iOS 13미만 - Objective-C

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray *restorableObjects))restorationHandler
{
	...
	if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
		NSString *url = userActivity.webpageURL.absoluteString;
		NSLog(@"url = %@", url);
		return YES;
	}
	...
	return NO;
}

 

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.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

반응형
블로그 이미지

SKY STORY

,
반응형

스마트폰 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

 

웹에서 앱을 실행할 경우 대부분 URL scheme을 이용한다.

그런데 만약 같은 scheme id를 사용하는 앱이 2개 이상이면 

어떻게 될까?  안드로이드 운영체제에서는 앱 선택창이 떠서

원하는 앱을 실행할 수 있지만 iOS에서는 무작위로 실행된다.

(물론 내부적으로 규칙은 있겠지만... 공개되어있지 않음)

 

※ iOS 14.4.1버전 부터 타임 트릭을 이용한 앱 존재 여부 체크가

사파리가 비활성화 되도 타이머가 진행되어 앱이 존재하더라도

앱 실행 후 앱스토어 이동이 동시에 일어나는 문제가 발생한다.

 

이럴경우를 위해 URL scheme 대신 도메인 주소로 앱을 

실행할 수 있도록 한 것이 Universal Link이다.

 

유니버셜링크 환경설정 방법을 알아보자.

 

 

개발자 사이트 접속

https://developer.apple.com

 

Certificates, Identifiers & Profiles / Identifiers 선택

 

적용할 App ID 선택하고 'Associated Domains' 체크 

 

Provisioning Profile 설정이 바뀌었으므로 다시 활성화 시킨다.

 

 

Xcode에서 'Associated Domains' 을 추가

 

applinks 도메인 추가

 

스마트폰 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.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

반응형

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

Universal Link (3/4) - 웹서버 환경 설정  (0) 2021.03.16
Universal Link (2/4) - 네이티브 링크 수신  (0) 2021.03.16
ARC or Non-ARC Compile Flag 설정  (0) 2021.02.05
String to CGFloat  (0) 2021.01.06
SceneDelegate 포인터 구하기  (0) 2021.01.05
블로그 이미지

SKY STORY

,