Created
August 21, 2016 16:20
-
-
Save amosavian/85f1e9dfc87c09b75d1ae761bbb60f72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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