Using swift and branch i am trying to create links in app so users can share the app and get rewarded if someone downloads the app with their link. This code is creating links that take the user to safari and says ‘safari cant open the page because the server cant be found’
Not sure what’s happening here, I’m able to create working quick links from the branch console.
import Foundation
import Branch
class BranchService {
static func createBranchLink(completion: @escaping (String?) -> Void) {
let userID: Int = AuthService.shared.userID ?? 0
let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: "user/invite")
branchUniversalObject.title = "xyz"
branchUniversalObject.contentDescription = "abc"
branchUniversalObject.contentMetadata.customMetadata = [
"user_id": String(userID)
]
let linkProperties = BranchLinkProperties()
linkProperties.feature = "sharing"
linkProperties.channel = "iOS"
linkProperties.addControlParam("$desktop_url", withValue: "https://-.com/invite")
linkProperties.addControlParam("$ios_url", withValue: "https://-.com/invite")
branchUniversalObject.getShortUrl(with: linkProperties) { (url, error) in
if error == nil, let url = url {
completion(url)
} else {
completion(nil)
print("Branch SDK Error: (String(describing: error))")
}
}
}
}