【发布时间】:2018-10-22 18:36:29
【问题描述】:
我正在尝试从设备向设备发送通知,我之前在我的其他应用程序上做过此操作,但由于某种原因我收到此错误消息
调用中的额外参数“方法”
在 alamofire.request 函数中的方法。我已经在网上搜索了几个小时,并且尝试了很多解决方案,但是没有任何对我有用的信息我得到了相同的错误消息。
func setUpPushNotification(fromDevice: String) {
let title = ""
let body = "You got a friend request"
let toDeviceID = fromDevice
var headers:HTTPHeaders = HTTPHeaders()
let Method = Alamofire.HTTPMethod.post
headers = ["Content-Type":"application/json","Authorization":"key=\(AppDelegate.SERVERKEY)"]
let notification = ["to":"\(toDeviceID)","notification":["body":body,"title":title,"badge":1,"sound":"default"]] as [String : Any]
Alamofire.request(AppDelegate.NOTIFICATION_URL as URLConvertible,
method: Method,
parameters: notification,
encoding: JSONEncoding.default,
headers: headers).responseJSON { (response) in
print(response)
}
}
感谢您的宝贵时间。 :)
【问题讨论】:
-
你能提供你正在尝试使用的 alamofire 版本吗?
-
@harsh 我正在使用 Alamofire 4.7.3 版
标签: swift swift4 alamofire http-method