Created
August 15, 2013 21:37
-
-
Save rileytestut/6245198 to your computer and use it in GitHub Desktop.
RSTWebViewControllerDownloadDelegate Protocol
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
@protocol RSTWebViewControllerDownloadDelegate <NSObject> | |
@optional | |
// Return YES to tell RSTWebViewController to create a [Redacted] object and start a [Redacted]DownloadTask. | |
// Or, if you choose to, you can return NO, and then implement your own downloading logic via [Redacted] with the NSURLRequest | |
- (BOOL)webViewController:(RSTWebViewController *)webViewController shouldStartDownloadWithRequest:(NSURLRequest *)request; | |
// If implemented, you must call startDownloadBlock, or else the download will never start. This was you can display an alert to the user asking if they want to download the file. | |
// If needed, you can keep a reference to the [Redacted]DownloadTask to suspend/cancel during the download. You can access the original request via downloadTask.originalRequest, or the current one via downloadTask.currentRequest | |
- (void)webViewController:(RSTWebViewController *)webViewController willStartDownloadWithTask:([Redacted]DownloadTask *)downloadTask startDownloadBlock:(RSTWebViewControllerStartDownloadBlock)completionHandler; | |
// Called periodically during download to allow you to keep track of progress | |
- (void)webViewController:(RSTWebViewController *)webViewController downloadTask:([Redacted]DownloadTask *)downloadTask totalBytesDownloaded:(int64_t)totalBytesDownloaded totalBytesExpected:(int64_t)totalBytesExpected; | |
// Download finished. You MUST read or copy the file over to your local directory before this message returns, as iOS deletes it straight afterwards. | |
// Due to Apple's implementation of [Redacted], webViewController:didCompleteDownloadWithError: will still be called with a nil error. | |
- (void)webViewController:(RSTWebViewController *)webViewController downloadTask:([Redacted]DownloadTask *)downloadTask didDownloadFileToURL:(NSURL *)fileURL; | |
// Last method before the download task is truly finished. Error may be nil if no error occured. | |
- (void)webViewController:(RSTWebViewController *)webViewController downloadTask:([Redacted]DownloadTask *)downloadTask didCompleteDownloadWithError:(NSError *)error; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment