ilvcs ilvcs - 3 months ago 9
Swift Question

Do i need to generate branch link again for fall back to my app?

Hi i am trying to incorporate branch app indexing into my app. I have a question regarding Branch App Indexing. The documentation shows like below,

let branchUniversalObject: BranchUniversalObject = BranchUniversalObject(canonicalIdentifier: "item/12345")
branchUniversalObject.canonicalUrl = "http://mypage.com/content/12345"
branchUniversalObject.title = "My Content Title"
branchUniversalObject.contentDescription = "My Content Description"
branchUniversalObject.imageUrl = "https://example.com/mycontent-12345.png"
branchUniversalObject.addMetadataKey("property1", value: "blue")
branchUniversalObject.addMetadataKey("property2", value: "red")

// register a view to add the item to the index
branchUniversalObject.registerView()


My questions are 1.if my content appeared in the google search results and if the user clicks on that, will he/she is going to redirect to AppStore or into the App if he/she got installed the app already ?? If not what should i do to achieve this with branch?.
2. Do i need to create a link using below method for App Indexing or above code is enough?

branchUniversalObject.getShortUrlWithLinkProperties(linkProperties, andCallback: { (optUrl: String?, error: NSError?) -> Void in
if error == nil, let url = optUrl {
print("got my Branch link to share: %@", url)
}
})


Thanks for helping.

Answer

Alex from Branch.io here:

To list the content for App Indexing, this code is sufficient:

branchUniversalObject.registerView()

Behind the scenes, this actually generates a link got submission to Google (or if the content is a duplicate of something already submitted for indexing, it finds that duplicate and reuses it). This also registers a view event for use in Branch's own content analytics view.

This code also does the above, and in addition will return a link to you for sharing, etc:

branchUniversalObject.getShortUrlWithLinkProperties()

The purpose of each is function is slightly different, and usually they would both be used in different places. registerView() when a piece of content is viewed, and getShortUrlWithLinkProperties() if/when you want to share it with another human. Since we dedupe everything, you don't need to worry about submitting the same content multiple times.

Comments