2

I have been using Branch SDK in Xcode 8, swift, iOS9.3 .

While creating link and passing through Airdrop , the added parameters is not getting in "params variable of :

branch.initSession(launchOptions: launchOptions, isReferrable: true, andRegisterDeepLinkHandler: {(params : [AnyHashable : Any]?, error) -> Void in

while print "params" its printing :

 ▿ 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

Mine created link:

 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)")
                    }
                }
            }
        })

How to fetch the added metaDataKey as parameter when app opens through DeepLink, like : params["product_picture"]

Febin Paul
  • 31
  • 5

1 Answers1

0

Alex from Branch here: the +clicked_branch_link: 0 param means that the SDK is not detecting any link for that device. This is why you're not getting your metadata back.

Does this only occur if you share the link through AirDrop? Could you try opening a link via either Notes or Messages and see if your metadata returns as expected?

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44
  • Thank for the reply. Yes I have tried through mail. On that, when I click the link from the mail. The app opens but the redirection not happing (Not getting the parameter). But when the apps opens through app.link , showing deepviews of iOS and the option for opening the app at the top, while opening the app through that link, I am getting the parameters and the redirection occurs. I am checking for the parameter in the didFinishLaunchingWithOptions method of AppDelegate class. – Febin Paul Oct 11 '16 at 05:05
  • In the "Events" category of "Liveview" section in Dashboard, when the app opens on clicking the shared link, the "session referring link url" is getting nil of that corresponding record. – Febin Paul Oct 11 '16 at 06:51
  • Hmmm...`didFinishLaunchingWithOptions` is the correct place to be checking for this. Would it be possible for you to record a screen capture of what happens when you click the link from mail? – Alex Bauer Oct 11 '16 at 16:04