Skip to content

Instantly share code, notes, and snippets.

@amosavian
Created August 21, 2016 16:20
Show Gist options
  • Save amosavian/85f1e9dfc87c09b75d1ae761bbb60f72 to your computer and use it in GitHub Desktop.
Save amosavian/85f1e9dfc87c09b75d1ae761bbb60f72 to your computer and use it in GitHub Desktop.
func removeScheduleTask() {
guard let scheduleId = dlItem?.scheduledIdentifier, let appId = OneSignal.app_id() else {
return
}
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: "https://onesignal.com/api/v1/notifications/\(scheduleId)?app_id=\(appId)")!) { (data, response, error) in
if let error = error {
Utility.UI.alertShow(NSLocalizedString("An error has been occured in server: \(error.localizedDescription)", comment: "schedule download task error"), withTitle: NSLocalizedString("Schedule", comment: "schedule download task error"), viewController: self)
}
if let r = response as? NSHTTPURLResponse where r.statusCode == 200 {
self.dlItem?.scheduledIdentifier = nil
self.dlItem?.scheduledTime = nil
self.dlItem?.saveState()
self.updateButtons()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment