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)