CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Dec 2014 |
Maintained by Clay Allsopp, Mert Dümenci, Clay Allsopp.
| Depends on: | |
| SVProgressHUD | ~> 1.0 |
| HexColors | ~> 2.0 |
| TransitionKit | ~> 2.1 |
| BlocksKit | ~> 2.2 |
HybridKit is a simple, extensible messaging system for your web/native hybrid mobile apps.
Using HybridKit for JavaScript, you can send commands from your web page to your native app for processing.
HybridKit uses command handlers for handling commands sent using the JavaScript library. HybridKit ships with useful defaults, or you can write completely new ones.
HybridKit for iOS requires CocoaPods. Add it to your Podfile:
pod 'HybridKit'Run pod install and you're off!
You can utilize HybridKit by using HYWebViewController instead of UIViewController. HYWebViewController will be ready to catch commands by registering the default command handlers automatically.
Setup HYWebViewController and load a URL.
HYWebViewController *webViewController = [[HYWebViewController alloc] initWithParams:@{@"url" : @"http://google.com"}];
// or
HYWebViewController *webViewController = [[HYWebViewController alloc] init];
webViewController.url = [NSURL URLWithString:@"http://google.com"];
[self presentViewController:webViewController animated:YES completion:nil];By default, HybridKit includes the following commands: alert, open_url, set_url, set_url_refresh, set_title, set_scroll_enabled, set_background_color, deceleration_rate, trigger_event, and javascript.
For more information about the built-in handlers, check the HybridKit-JS Wiki.
You can create new command handlers for custom commands invoked using the JavaScript library easily.
Simply create a HYWebViewCommand subclass and override the handleCommandString:dictionary & respondsToCommandString methods:
@interface HideNavigationBarHandler : HYWebViewCommand
@end
@implementation HideNavigationBarHandler
-(void)handleCommandString:(NSString *)commandString dictionary:(NSDictionary *)commandDictionary {
if ([commandString isEqualToString:@"hide_navbar"]) {
self.webViewController.navigationController.navigationBarHidden = [commandDictionary[@"hidden"] boolValue];
}
}
- (BOOL)respondsToCommandString:(NSString *)commandString {
return [commandString isEqualToString:@"hide_navbar"];
}
@endRegister the new command handler to a HYWebViewController instance.
[hybridKitViewController registerCommandHandler:[HideNavigationBarHandler new]];Invoke your new command using the JavaScript library.
HybridKit.runCommand("hide_navbar", {hidden: true});HybridKit for iOS is available under the MIT license. See the LICENSE file for more info.