Last active
August 29, 2015 14:15
-
-
Save nhindman/a8cca2f6e9340578e201 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // | |
| // URX.m | |
| // | |
| // Created by Nate Hindman. | |
| // | |
| // | |
| #import "URX.h" | |
| #import <URXWidgets/URXWidgets.h> | |
| @implementation URX | |
| UIWebView *webView; | |
| -(CDVPlugin*) initWithWebView:(UIWebView*)theWebView{ | |
| webView = theWebView; | |
| self = [super initWithWebView: theWebView]; | |
| return self; | |
| } | |
| - (void) searchSongs: (CDVInvokedUrlCommand*)command{ | |
| NSArray *arguments = command.arguments; | |
| NSString *callbackId = command.callbackId; | |
| CDVPluginResult *pluginResult = nil; | |
| NSString *javaScript = nil; | |
| NSMutableArray *returnArgs = [[NSMutableArray alloc] init]; | |
| NSString *search = [arguments objectAtIndex: 0]; | |
| URXListenButtonView *buttonView = [[URXListenButtonView alloc] init]; | |
| buttonView.initialQuery = search; | |
| [self.viewController.view insertSubview:buttonView aboveSubview:webView]; | |
| [buttonView sendActionsForControlEvents:UIControlEventTouchDown]; | |
| [buttonView sendActionsForControlEvents:UIControlEventTouchUpInside]; | |
| [buttonView removeFromSuperview]; | |
| pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:returnArgs]; | |
| javaScript = [pluginResult toSuccessCallbackString:callbackId]; | |
| [self writeJavascript:[NSString stringWithFormat:@"window.setTimeout(function (){%@;},0);", javaScript]]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment