#import "AppDelegate+threedeetouch.h"#import "ThreeDeeTouch.h"#import <objc/runtime.h>#import "MainViewController.h"@implementationAppDelegate(threedeetouch)-(void)application:(UIApplication*)applicationperformActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItemcompletionHandler:(void(^)(BOOLsucceeded))completionHandler{NSString*jsFunction=@"ThreeDeeTouch.onHomeIconPressed";NSString*params=[NSStringstringWithFormat:@"{'type':'%@', 'title': '%@'}",shortcutItem.type,shortcutItem.localizedTitle];NSString*result=[NSStringstringWithFormat:@"%@(%@)",jsFunction,params];[selfcallJavascriptFunctionWhenAvailable:result];}// check every x seconds for the phone app to be ready, or stop from glance.didDeactivate-(void)callJavascriptFunctionWhenAvailable:(NSString*)function{ThreeDeeTouch*threeDeeTouch=[self.viewControllergetCommandInstance:@"ThreeDeeTouch"];if(threeDeeTouch.initDone){if([threeDeeTouch.webViewrespondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]){// UIWebView[threeDeeTouch.webViewperformSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:)withObject:functionwaitUntilDone:NO];}elseif([threeDeeTouch.webViewrespondsToSelector:@selector(evaluateJavaScript:completionHandler:)]){// WKWebView[threeDeeTouch.webViewperformSelector:@selector(evaluateJavaScript:completionHandler:)withObject:functionwithObject:nil];}else{NSLog(@"No compatible method found to communicate 3D Touch callback to the webview. Please notify the plugin author.");}}else{dispatch_after(dispatch_time(DISPATCH_TIME_NOW,25*NSEC_PER_MSEC),dispatch_get_main_queue(),^{[selfcallJavascriptFunctionWhenAvailable:function];});}}-(void)applicationDidBecomeActive:(UIApplication*)application{}@end