【发布时间】:2015-08-13 09:35:01
【问题描述】:
我正在尝试在我的应用中实现交互式推送通知。应用成功收到通知。
收到通知后,我在锁定屏幕上有两个按钮。它们都应该启动两个 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}
【问题讨论】:
标签: ios swift push-notification