Branch.io 링크가 앱이 이미 설치된 경우 데이터를 가져 오지 못합니다. 앱 설치 링크가 앱을 직접 열지 만 데이터가 누락 된 경우. 하지만 앱 스토어로 리디렉션 한 다음 지점 링크를 다시 클릭하고 앱을 직접 연 다음 데이터가 제공됩니다. 아래 코드를 안내하고 안내하십시오.Branch.io - 앱을 열고 있지만 데이터를 가져 오지 않는 링크
업데이트 :
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
let branch: Branch = Branch.getInstance()
branch.setDebug()
branch.initSessionWithLaunchOptions(launchOptions, andRegisterDeepLinkHandler: {params, error in
if error == nil {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
print("params: %@", params.description)
print(params["event_id"])
if let url = params["event_id"] as? NSInteger {
let strEventID = String(url)
print(strEventID)
})
self.window?.rootViewController = nav
self.window?.makeKeyAndVisible()
return true
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
Branch.getInstance().handleDeepLink(url)
if(sourceApplication == "com.linkedin.LinkedIn")
{
if(LISDKCallbackHandler.shouldHandleUrl(url))
{
return LISDKCallbackHandler.application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
}
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool {
// handler for Universal Links
Branch.getInstance().continueUserActivity(userActivity)
return true
}
// Called when a notification is received and the app is in the
// foreground (or if the app was in the background and the user clicks on the notification).
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
{
Branch.getInstance().handlePushNotification(userInfo)
if(UserSingleton.sharedInstance.accessToken != kEmptyString)
{
if let aps = userInfo["aps"] as? NSDictionary {
var title = kEmptyString
var message = kEmptyString
var inviteID = kEmptyString
var statusType = kEmptyString
if let inviteIDLocal = aps.valueForKey("id") as? NSNumber
{
inviteID = "\(inviteIDLocal)"
}
else if let inviteIDLocal = aps.valueForKey("id") as? String
{
inviteID = inviteIDLocal
}
else
{
inviteID = "0"
}
if let statusTypeLocal = aps.valueForKey("status_type") as? String
{
statusType = statusTypeLocal
}
if let titleLocal = aps.valueForKey("alert")?.valueForKey("title") as? String
{
title = titleLocal
}
if let messageLocal = aps.valueForKey("alert")?.valueForKey("body") as? String
{
message = messageLocal
}
CommonFunctions.addNotificationBar(title,message: message, inviteID: inviteID,statusType: statusType)
}
}
}
이것은'continueUserActivity' 구현에 문제가있는 것처럼 들립니다. AppDelegate 파일에서'didFinishLaunching' 메서드 전체를 게시 할 수 있습니까? –
확실한 @AlexBauer 업데이트 된 질문을 확인하십시오 –