我正在尝试在我的应用中实现交互式推送通知。应用成功收到通知。
收到通知后,我在锁定屏幕上有两个按钮。它们都应该启动两个 Web 服务
这是我在 application handleActionWithIdentifier
中的代码
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [NSObject : AnyObject], completionHandler: () -> Void) {
let aps = userInfo["aps"] as NSDictionary
let id = aps["id"] as Int
let notification = Notifications()
notification.notificationId = NSNumber(integer: id)
if identifier == "APPROVE"{
APIManager.sharedInstance.approveApprovalRequest(notification)
}
else if identifier == "DELETE"{
APIManager.sharedInstance.dismissBulletin(notification)
}
completionHandler()
}
我用过
NSURLSession.sharedSession().dataTaskWithRequest(request,
completionHandler: { (data, response, error) -> Void in}).resume()
用于网络服务调用。
但它返回连接错误。
我该如何解决这个问题。任何帮助表示赞赏。
编辑:
这是我在日志中收到的错误
Error Domain=NSPOSIXErrorDomain Code=9 "The operation couldn’t be completed.Bad file descriptor"
UserInfo=0x1552ca00 {_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=9}
最佳答案
这对我有用。
let data = NSURLConnection.sendSynchronousRequest(request, returningResponse: response, error: error)
关于ios - 使用交互式推送通知调用 web 服务 iOS 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31984530/