From 543515bb3cc78fc057333b305b1f66093b625ccb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jul 2014 15:42:11 -0300 Subject: [PATCH] sending ios support --- src/ios/startApp.h | 8 ++++++++ src/ios/startApp.m | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/ios/startApp.h create mode 100644 src/ios/startApp.m diff --git a/src/ios/startApp.h b/src/ios/startApp.h new file mode 100644 index 0000000..a835f9a --- /dev/null +++ b/src/ios/startApp.h @@ -0,0 +1,8 @@ +#import + +@interface startApp : CDVPlugin + +- (void)check:(CDVInvokedUrlCommand*)command; +- (void)start:(CDVInvokedUrlCommand*)command; + +@end \ No newline at end of file diff --git a/src/ios/startApp.m b/src/ios/startApp.m new file mode 100644 index 0000000..b851344 --- /dev/null +++ b/src/ios/startApp.m @@ -0,0 +1,41 @@ +#import "startApp.h" +#import + +@implementation startApp + +- (void)check:(CDVInvokedUrlCommand*)command { + + CDVPluginResult* pluginResult = nil; + + NSString* scheme = [command.arguments objectAtIndex:0]; + + if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:(true)]; + } + else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsBool:(false)]; + } + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + +} + +- (void)start:(CDVInvokedUrlCommand*)command { + + CDVPluginResult* pluginResult = nil; + + NSString* scheme = [command.arguments objectAtIndex:0]; + + if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:scheme]]) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:scheme]]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:(true)]; + } + else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsBool:(false)]; + } + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + +} + +@end \ No newline at end of file