여러분. 내 질문은 : 딥 링크 URL에서 데이터를 어떻게 가져올 수 있습니까? 두 개의 앱이 있고 딥 링크를 사용하여 app1에서 app2로 데이터를 보내고 싶습니다. app1에 app2를 클릭하고 열 수있는 버튼이 있습니다. 그러면 앱 2는 딥 링크 URL로 app1에서 데이터를 가져옵니다.
다음은 app1의 버튼 보내기 코드입니다.
@IBAction func btnSend_Clicked(_ sender: Any) {
let text = self.txtInput.text?.replacingOccurrences(of: " ", with: "%20")
UIApplication.shared.open(URL(string: "myapp://?code=\(text!)")!, options: [:], completionHandler: nil)
}
그렇다면 app2의 딥 링크 URL (코드 매개 변수)에서 데이터를 가져 오려면 어떻게해야합니까?
도와 주셔서 정말 감사합니다 !!!!
Appdelegate에서이 코드를 구현합니다.
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
let items = (urlComponents?.queryItems)! as [NSURLQueryItem]
if (url.scheme == "myapp") {
var vcTitle = ""
if let _ = items.first, let propertyName = items.first?.name, let propertyValue = items.first?.value {
vcTitle = url.query!//"propertyName"
}
}
return false
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다