使用 Branch 框架时应用程序崩溃
App crash when I use the Branch framework
我使用 Branch SDK 深入 link 到 iOS 应用程序。问题出现在以下情况,如果快速向第三方应用程序(例如Slack、Facebook)发送deep link,则会出现应用程序崩溃。控制台显示以下结果 [core] SLComposeViewController dealloc <SLComposeViewController: 0x11fbf03a0>.
我该如何解决?
我的代码
func shareCardDetail(_ cardModel: CardModel) {
let shareText = "What do you think about this?"
let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: ("cardId/\(cardModel.id)"))
branchUniversalObject.title = cardModel.title
branchUniversalObject.contentDescription = ""
branchUniversalObject.imageUrl = cardModel.photoURLsProperties.placeVenuePhoto
branchUniversalObject.addMetadataKey(CardKeys.cardID.rawValue, value: cardModel.id)
if let placeAvatarURLString = cardModel.photoURLsProperties.placeVenuePhoto {
branchUniversalObject.addMetadataKey("placeAvatarURLString", value: placeAvatarURLString)
}
branchUniversalObject.addMetadataKey("title", value: cardModel.title)
branchUniversalObject.addMetadataKey("isAutoGeneratedCard", value: "false")
let fullLocationName = cardModel.location.fullLocationName
branchUniversalObject.addMetadataKey("fullLocationName", value: fullLocationName)
branchUniversalObject.addMetadataKey(CardKeys.ownerID.rawValue, value: cardModel.ownerID)
branchUniversalObject.addMetadataKey(ParametersKeywords.type.rawValue, value: ModeKeywords.shareCard.rawValue)
branchUniversalObject.addMetadataKey("availableSeats", value: cardModel.peopleProperties.availableSeats.description)
if let coordinate = cardModel.location.coordinate {
branchUniversalObject.addMetadataKey("latitude", value: coordinate.latitude.description)
branchUniversalObject.addMetadataKey("longitude",value: coordinate.longitude.description)
}
let linkProperties = BranchLinkProperties()
linkProperties.feature = "sharing"
linkProperties.addControlParam("$desktop_url", withValue: "http://www.example.com")
linkProperties.addControlParam("$ios_url", withValue: "example://")
guard let topViewController = UIApplication.topViewController() else { return }
branchUniversalObject.showShareSheet(with: linkProperties, andShareText: shareText, from: topViewController) { (text, success) in
debugPrint("done showing share sheet!")
}
}
我更改了我的代码并且它有效。
func shareCardDetail(_ cardModel: CardModel) {
let shareText = "What do you think about this?"
let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: ("cardId/\(cardModel.id)"))
branchUniversalObject.title = cardModel.title
branchUniversalObject.contentDescription = ""
branchUniversalObject.imageUrl = cardModel.photoURLsProperties.placeVenuePhoto
branchUniversalObject.addMetadataKey(CardKeys.cardID.rawValue, value: cardModel.id)
if let placeAvatarURLString = cardModel.photoURLsProperties.placeVenuePhoto {
branchUniversalObject.addMetadataKey("placeAvatarURLString", value: placeAvatarURLString)
}
branchUniversalObject.addMetadataKey("title", value: cardModel.title)
branchUniversalObject.addMetadataKey("isAutoGeneratedCard", value: "false")
let fullLocationName = cardModel.location.fullLocationName
branchUniversalObject.addMetadataKey("fullLocationName", value: fullLocationName)
branchUniversalObject.addMetadataKey(CardKeys.ownerID.rawValue, value: cardModel.ownerID)
branchUniversalObject.addMetadataKey(ParametersKeywords.type.rawValue, value: ModeKeywords.shareCard.rawValue)
branchUniversalObject.addMetadataKey("availableSeats", value: cardModel.peopleProperties.availableSeats.description)
if let coordinate = cardModel.location.coordinate {
branchUniversalObject.addMetadataKey("latitude", value: coordinate.latitude.description)
branchUniversalObject.addMetadataKey("longitude",value: coordinate.longitude.description)
}
let linkProperties = BranchLinkProperties()
linkProperties.feature = "sharing"
linkProperties.addControlParam("$desktop_url", withValue: "http://www.example.com")
linkProperties.addControlParam("$ios_url", withValue: "example://")
guard let topViewController = UIApplication.topViewController() else { return }
guard let branchShareLink = BranchShareLink(universalObject: branchUniversalObject, linkProperties: linkProperties) else { return }
branchShareLink.shareText = shareText
branchShareLink.presentActivityViewController(from: topViewController, anchor: nil)
}
我使用 Branch SDK 深入 link 到 iOS 应用程序。问题出现在以下情况,如果快速向第三方应用程序(例如Slack、Facebook)发送deep link,则会出现应用程序崩溃。控制台显示以下结果 [core] SLComposeViewController dealloc <SLComposeViewController: 0x11fbf03a0>.
我该如何解决?
我的代码
func shareCardDetail(_ cardModel: CardModel) {
let shareText = "What do you think about this?"
let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: ("cardId/\(cardModel.id)"))
branchUniversalObject.title = cardModel.title
branchUniversalObject.contentDescription = ""
branchUniversalObject.imageUrl = cardModel.photoURLsProperties.placeVenuePhoto
branchUniversalObject.addMetadataKey(CardKeys.cardID.rawValue, value: cardModel.id)
if let placeAvatarURLString = cardModel.photoURLsProperties.placeVenuePhoto {
branchUniversalObject.addMetadataKey("placeAvatarURLString", value: placeAvatarURLString)
}
branchUniversalObject.addMetadataKey("title", value: cardModel.title)
branchUniversalObject.addMetadataKey("isAutoGeneratedCard", value: "false")
let fullLocationName = cardModel.location.fullLocationName
branchUniversalObject.addMetadataKey("fullLocationName", value: fullLocationName)
branchUniversalObject.addMetadataKey(CardKeys.ownerID.rawValue, value: cardModel.ownerID)
branchUniversalObject.addMetadataKey(ParametersKeywords.type.rawValue, value: ModeKeywords.shareCard.rawValue)
branchUniversalObject.addMetadataKey("availableSeats", value: cardModel.peopleProperties.availableSeats.description)
if let coordinate = cardModel.location.coordinate {
branchUniversalObject.addMetadataKey("latitude", value: coordinate.latitude.description)
branchUniversalObject.addMetadataKey("longitude",value: coordinate.longitude.description)
}
let linkProperties = BranchLinkProperties()
linkProperties.feature = "sharing"
linkProperties.addControlParam("$desktop_url", withValue: "http://www.example.com")
linkProperties.addControlParam("$ios_url", withValue: "example://")
guard let topViewController = UIApplication.topViewController() else { return }
branchUniversalObject.showShareSheet(with: linkProperties, andShareText: shareText, from: topViewController) { (text, success) in
debugPrint("done showing share sheet!")
}
}
我更改了我的代码并且它有效。
func shareCardDetail(_ cardModel: CardModel) {
let shareText = "What do you think about this?"
let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: ("cardId/\(cardModel.id)"))
branchUniversalObject.title = cardModel.title
branchUniversalObject.contentDescription = ""
branchUniversalObject.imageUrl = cardModel.photoURLsProperties.placeVenuePhoto
branchUniversalObject.addMetadataKey(CardKeys.cardID.rawValue, value: cardModel.id)
if let placeAvatarURLString = cardModel.photoURLsProperties.placeVenuePhoto {
branchUniversalObject.addMetadataKey("placeAvatarURLString", value: placeAvatarURLString)
}
branchUniversalObject.addMetadataKey("title", value: cardModel.title)
branchUniversalObject.addMetadataKey("isAutoGeneratedCard", value: "false")
let fullLocationName = cardModel.location.fullLocationName
branchUniversalObject.addMetadataKey("fullLocationName", value: fullLocationName)
branchUniversalObject.addMetadataKey(CardKeys.ownerID.rawValue, value: cardModel.ownerID)
branchUniversalObject.addMetadataKey(ParametersKeywords.type.rawValue, value: ModeKeywords.shareCard.rawValue)
branchUniversalObject.addMetadataKey("availableSeats", value: cardModel.peopleProperties.availableSeats.description)
if let coordinate = cardModel.location.coordinate {
branchUniversalObject.addMetadataKey("latitude", value: coordinate.latitude.description)
branchUniversalObject.addMetadataKey("longitude",value: coordinate.longitude.description)
}
let linkProperties = BranchLinkProperties()
linkProperties.feature = "sharing"
linkProperties.addControlParam("$desktop_url", withValue: "http://www.example.com")
linkProperties.addControlParam("$ios_url", withValue: "example://")
guard let topViewController = UIApplication.topViewController() else { return }
guard let branchShareLink = BranchShareLink(universalObject: branchUniversalObject, linkProperties: linkProperties) else { return }
branchShareLink.shareText = shareText
branchShareLink.presentActivityViewController(from: topViewController, anchor: nil)
}