반응형

다음은 스크린 캡쳐 이벤트 처리 방법이다.

말 그대로 이벤트만 받는다. 막는건 안된다.

// Objective C
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification
                                                  object:nil
                                                   queue:mainQueue
                                              usingBlock:^(NSNotification *note) {
                                                 // executes after screenshot
                                              }];


// Swift
NotificationCenter.default.addObserver(
    forName: UIApplication.userDidTakeScreenshotNotification,
    object: nil,
    queue: .main) { notification in
        //executes after screenshot
}



방법 1
func detectScreenShot(action: @escaping () -> ()) {
    let mainQueue = OperationQueue.main
    NotificationCenter.default.addObserver(forName: UIApplication.userDidTakeScreenshotNotification, object: nil, queue: mainQueue) { notification in
        // executes after screenshot
        action()
    }
}


방법  2
func detectScreenShot(action: () -> ()) {
    let mainQueue = NSOperationQueue.mainQueue()
    NSNotificationCenter.defaultCenter().addObserverForName(UIApplicationUserDidTakeScreenshotNotification, object: nil, queue: mainQueue) { notification in
        // executes after screenshot
        action()
    }
}

방법1, 2 실행방법 
detectScreenShot { () -> () in
    print("User took a screen shot")
}
반응형
블로그 이미지

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

,
반응형

Objective-C 개발시 ARC 혹은 MRC를 선택하여 개발을 한다. ARC는 Objective-C Class에만 해당되어 만약 Core Foundation과 같이 C/C++ 계열의 API는 Type Casting을 해줘야 ARC를 사용할 수 있다. (일명 Toll-Free Bridging) 오늘 소개할 내용은 *.m 파일에 ARC or Non-ARC Compile Flag를 사용하는 방법이며, 위에 얘기한 것처럼 Type Casting 없이 개별 파일에 Compile Flag만 변경해서도 사용할 수 있는 방법이다. 

우선 프로젝트 폴더의 상단 프로젝트명을 선택해서 나오는 Target에서  Build Phases중 Compile Sources를 열어보면 Compile될 *m파일 리스트가 보이며 Compile Flag 변경을 원하는 파일을 더블클릭하면 변경가능하다.

 

ARC 변경

-fobjc-arc

 

Non-ARC변경

-fno-obj-arc

반응형

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

Universal Link (2/4) - 네이티브 링크 수신  (0) 2021.03.16
Universal Link (1/4) - 네이티브 환경설정  (0) 2021.03.16
String to CGFloat  (0) 2021.01.06
SceneDelegate 포인터 구하기  (0) 2021.01.05
앱 호출 (URL scheme)  (0) 2021.01.05
블로그 이미지

SKY STORY

,

String to CGFloat

개발/iOS 2021. 1. 6. 09:45
반응형
let sHeight = "100.0"
guard let num = NumberFormatter().number(from: sHeight) else { return 100.0 }
let fHeight = CGFloat(truncating: num)
print("\(fHeight)")
반응형

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

Universal Link (1/4) - 네이티브 환경설정  (0) 2021.03.16
ARC or Non-ARC Compile Flag 설정  (0) 2021.02.05
SceneDelegate 포인터 구하기  (0) 2021.01.05
앱 호출 (URL scheme)  (0) 2021.01.05
URL query 파싱 및 json string 변환  (0) 2020.12.17
블로그 이미지

SKY STORY

,
반응형

방법 1

// Swift
let sd = self.view.window.windowScene.delegate

// Objective-C
SceneDelegate *sd = self.view.window.windowScene.delegate;

 

방법 2

Swift :

//
// UIResponder+Scene.swift
//

import UIKit

@available(iOS 13.0, *)
extension UIResponder {
    @objc var scene: UIScene? {
        return nil
    }
}

@available(iOS 13.0, *)
extension UIScene {
    @objc override var scene: UIScene? {
        return self
    }
}

@available(iOS 13.0, *)
extension UIView {
    @objc override var scene: UIScene? {
        if let window = self.window {
            return window.windowScene
        } else {
            return self.next?.scene
        }
    }
}

@available(iOS 13.0, *)
extension UIViewController {
    @objc override var scene: UIScene? {
        // Try walking the responder chain
        var res = self.next?.scene
        if (res == nil) {
            // That didn't work. Try asking my parent view controller
            res = self.parent?.scene
        }
        if (res == nil) {
            // That didn't work. Try asking my presenting view controller 
            res = self.presentingViewController?.scene
        }

        return res
    }
}

 

Objective-C :

//
// UIResponder+Scene.h
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIResponder (Scene)

@property (nonatomic, readonly, nullable) UIScene *scene API_AVAILABLE(ios(13.0));

@end

NS_ASSUME_NONNULL_END





// 
// UIResponder+Scene.m
//

#import "ViewController+Scene.h"

@implementation UIResponder (Scene)

- (UIScene *)scene {
    return nil;
}

@end

@implementation UIScene (Scene)

- (UIScene *)scene {
    return self;
}

@end

@implementation UIView (Scene)

- (UIScene *)scene {
    if (self.window) {
        return self.window.windowScene;
    } else {
        return self.nextResponder.scene;
    }
}

@end

@implementation UIViewController (Scene)

- (UIScene *)scene {
    UIScene *res = self.nextResponder.scene;
    if (!res) {
        res = self.parentViewController.scene;
    }
    if (!res) {
        res = self.presentingViewController.scene;
    }

    return res;
}

@end

 

원문 : 
stackoverflow.com/questions/56588843/uiapplication-shared-delegate-equivalent-for-scenedelegate-xcode11

 

반응형

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

ARC or Non-ARC Compile Flag 설정  (0) 2021.02.05
String to CGFloat  (0) 2021.01.06
앱 호출 (URL scheme)  (0) 2021.01.05
URL query 파싱 및 json string 변환  (0) 2020.12.17
디버깅 차단 처리 (Anti Debug)  (0) 2020.12.15
블로그 이미지

SKY STORY

,