tHatpart
tHatpart

Reputation: 1146

Branch Creating Bad Links in Swift

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")
    linkProperties.addControlParam("$uri_redirect_mode", withValue: "0")


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

Branch's only documentation (https://help.branch.io/faq/docs/safari-error-safari-cannot-open-this-page-because-address-is-invalid) on this hasn't helped

EDIT: iOS integration is 100%, link configuration is 100%, web is 0%.

We are able to create quick links in the dashboard and have those work. The swift code seems to be creating different links than in quick links

Upvotes: -1

Views: 93

Answers (1)

Guru Prasadh
Guru Prasadh

Reputation: 11

The Branch SDK function seems to be fine. But I also noticed that you have added $iOS_URL has some invalid link that might caused this issue. Add some valid links to resolve this.

Sharing some related documents that might help you. https://help.branch.io/developers-hub/docs/ios-basic-integration https://help.branch.io/developers-hub/docs/ios-advanced-features

Upvotes: 0

Related Questions