Created
March 27, 2015 05:21
-
-
Save yasuoza/65ade65c942f96fe0150 to your computer and use it in GitHub Desktop.
Install configuration profile through iOS application with CocoaHTTPServer
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
/* | |
* Be sure not to close local server at `applicationDidEnterBackground:`. | |
* This causes file not found error in Safari. | |
*/ | |
class LocalHTTPConnection: HTTPConnection { | |
override func httpResponseForMethod(method: String!, URI path: String!) -> NSObject! { | |
if path == LocalWebViewRouter.Profile.URL.path { | |
return LocalProfileReponse(filePath: self.filePathForURI(path), forConnection: self) | |
} | |
return super.httpResponseForMethod(method, URI: path) | |
} | |
} | |
class LocalProfileReponse: HTTPFileResponse { | |
override func httpHeaders() -> [NSObject : AnyObject]! { | |
return ["Content-Type": "application/x-apple-aspen-config"] | |
} | |
} | |
self.server.setConnectionClass(LocalHTTPConnection.self) | |
self.server.start() | |
UIApplication.sharedApplication.openURL(url: LocalWebViewRouter.Profile.URL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment