Xcode 8、swift、iOS9.3 で Branch SDK を使用しています。
リンクを作成して Airdrop を通過しているときに、追加されたパラメータが「の params 変数:
branch.initSession(launchOptions: launchOptions, isReferrable: true, andRegisterDeepLinkHandler: {(params : [AnyHashable : Any]?, error) -> Void in
while print "params" その印刷:
▿ Optional<Dictionary<AnyHashable, Any>>
▿ some : 2 elements
▿ 0 : 2 elements
▿ .0 : AnyHashable("+clicked_branch_link")
- value : "+clicked_branch_link"
- .1 : 0
▿ 1 : 2 elements
▿ .0 : AnyHashable("+is_first_session")
- value : "+is_first_session"
- .1 : 0
私が作成したリンク:
branchUniversalObject = BranchUniversalObject(canonicalIdentifier: "item/1")
branchUniversalObject.title = "Meet Mr. Squiggles"
branchUniversalObject.contentDescription = "Your friend Josh has invited you to meet his awesome monster, Mr. Squiggles!"
branchUniversalObject.imageUrl = "https://example.com/monster-pic-12345.png"
branchUniversalObject.addMetadataKey("userId", value: "12345")
branchUniversalObject.addMetadataKey("userName", value: "Josh")
branchUniversalObject.addMetadataKey("monsterName", value: "Mr. Squiggles")
branchUniversalObject.addMetadataKey("product_picture", value: "Mr. Squiggles product_picture")
branchUniversalObject.automaticallyListOnSpotlight = true
branchUniversalObject.userCompletedAction(BNCRegisterViewEvent)
linkProperties = BranchLinkProperties()
linkProperties.feature = "share"
linkProperties.addControlParam("$desktop_url", withValue: "http://example.com/home")
linkProperties.addControlParam("$ios_url", withValue: "http://example.com/ios")
branchUniversalObject.getShortUrl(with: linkProperties, andCallback: { (optUrl: String?, error: Error?) in
if error == nil, let url = optUrl {
print("got my Branch link to share: %@", url)
DispatchQueue.main.async {
self.branchUniversalObject.showShareSheet(with: self.linkProperties,
andShareText: "Super amazing thing I want to share!",
from: self) { (activity: String?, success: Bool) in
print("done showing share sheet! : \(success)")
}
}
}
})
次のように、DeepLink を介してアプリを開くときに、追加された metaDataKey をパラメーターとして取得する方法: params["product_picture"]