使用以下代码时出现错误。
这是我的代码:
let params = [ "referringUsername": "vihar",
"referringUserId": "78457" ]
Branch.getInstance().getShortURL(withParams: params, andChannel: "SMS", andFeature: "Referral", andCallback: { (url: String!, error: NSError!) -> Void in
if (error == nil) {
let vc = UIActivityViewController(activityItems: [url], applicationActivities: [])
self.present(vc, animated: true, completion: nil)
} else {
print("Genrate Error")
}
})
我收到此错误:
无法将类型'((String !, NSError!)-> Void'的值转换为预期的参数类型'callbackWithUrl!' (aka'ImplicitlyUnwrappedOptional <(Optional
,Optional )->()>')
答案 0 :(得分:2)
替换
Branch.getInstance().getShortURL(withParams: params, andChannel: "SMS",
andFeature: "Referral", andCallback: { (url: String!, error: NSError!) -> Void in
使用
Branch.getInstance().getShortURL(withParams: params, andChannel: "SMS",
andFeature: "Referral", andCallback: { (url, error) in
答案 1 :(得分:1)
使用此代码:
Branch.getInstance()。getShortURL(withParams:params,andChannel:“ SMS”, andFeature:“引荐”,andCallback:{(网址,错误)在 分享
如documentation 中所述如有任何其他疑问,请写信至integration@branch.io。