Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Merge pull request #114 from galexandrov/galexandrov/post-notification
Browse files Browse the repository at this point in the history
Post Notification When WebServer is created
  • Loading branch information
EddyVerbruggen committed Jun 11, 2015
2 parents 4a0007f + 9accd3d commit 8919b1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/ios/AppDelegate+WKWebViewPolyfill.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@implementation AppDelegate (WKWebViewPolyfill)

NSString *const FileSchemaConstant = @"file://";
NSString *const ServerCreatedNotificationName = @"WKWebView.WebServer.Created";
GCDWebServer* _webServer;
NSMutableDictionary* _webServerOptions;
NSString* appDataFolder;
Expand Down Expand Up @@ -44,14 +45,16 @@ - (void) createWindowAndStartWebServer:(BOOL) startWebServer {
NSString *directoryPath = myMainViewController.wwwFolderName;
_webServer = [[GCDWebServer alloc] init];
_webServerOptions = [NSMutableDictionary dictionary];

// Add GET handler for local "www/" directory
[_webServer addGETHandlerForBasePath:@"/"
directoryPath:directoryPath
indexFilename:nil
cacheAge:60
allowRangeRequests:YES];


[[NSNotificationCenter defaultCenter] postNotificationName:ServerCreatedNotificationName object: @[myMainViewController, _webServer]];

[self addHandlerForPath:@"/Library/"];
[self addHandlerForPath:@"/Documents/"];

Expand Down
2 changes: 0 additions & 2 deletions src/ios/MyMainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ - (void)viewDidLoad
}
config.suppressesIncrementalRendering = suppressesIncrementalRendering;
[self createGapView:config];

[super viewDidLoad];
}

[self.wkWebView loadRequest: [NSURLRequest requestWithURL:appURL]];
Expand Down

0 comments on commit 8919b1f

Please sign in to comment.