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