Trying to implement Apple business chat button in app

Hello,

my question is the following: I am trying to implement a button for the business apple chat in my iOS app, tapping the button, redirects always to the same app page:

I type in the code the following:

Code Block @IBOutlet weak var chatButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Check to see if device iOS version is supported
// Hide chat button if device is not supported
if #available(iOS 11.3, *){
chatButton.isHidden = false
}
else {
chatButton.isHidden = true
}
}
func BCUrlConstructor (intentId: String, groupId: String, bodyParam: String) -> URL {
let bizId = "" // Sets the Business ID
// Construct Business Chat URL using business ID, intent ID, group ID, and preset body text
let url : NSString = "https://bcrw.apple.com/sms:open?service=iMessage&recipient=urn:biz:\(bizId)&biz-intent-id=\(intentId)&bizgroup-id=\(groupId)&body=\(bodyParam)" as NSString
let urlString : NSString = url.addingPercentEncoding(withAllowedCharacters:NSCharacterSet.urlQueryAllowed)! as NSString
let bcUrl : NSURL = NSURL(string: urlString as String)!
return bcUrl as URL
}
@IBAction func chatButtonTap(_ sender: Any) {
//Send Intent parameters to construct Business Chat URL
let url = BCUrlConstructor(intentId: "INTENTID", groupId: "GROUPID", bodyParam: "PRESET TEXT")
// Launch Business Chat
UIApplication.shared.open(url)
}

with my business chat ID already online and ready for use.


I set the swift file as UIButton with reference in the mainboard as the following:

Declaration
@interface UIButton : UIControl

The class name is UIButton and the module is the name of the swift file.

In the button I have set a triggered segues as the following: action - connect Push, I have tried also without a seques.

The class of the button is UIButton and the module is inherit module from target

When I push the button the page redirect always to itself.

Where I am wrong?


Can you please help?

Thank you


Trying to implement Apple business chat button in app
 
 
Q