Merge pull request #7 from vitorsgomes/master

to parent project
This commit is contained in:
Лампуша
2014-07-11 15:31:03 +04:00
4 changed files with 77 additions and 1 deletions
+14 -1
View File
@@ -46,4 +46,17 @@ navigator.startApp.start([
function(error) { /* error */
console.log('47', error);
});
```
```
**Start application in iOS**
```js
navigator.startApp.start("twitter://", function(message) { /* success */
console.log(message); // => OK
},
function(error) { /* error */
console.log('47', error);
});
```
+14
View File
@@ -24,4 +24,18 @@
<source-file src="src/android/startApp.java" target-dir="src/org/apache/cordova/startapp" />
</platform>
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="startApp">
<param name="ios-package" value="startApp"/>
</feature>
</config-file>
<header-file src="src/ios/startApp.h"/>
<source-file src="src/ios/startApp.m"/>
</platform>
</plugin>
+8
View File
@@ -0,0 +1,8 @@
#import <Cordova/CDV.h>
@interface startApp : CDVPlugin
- (void)check:(CDVInvokedUrlCommand*)command;
- (void)start:(CDVInvokedUrlCommand*)command;
@end
+41
View File
@@ -0,0 +1,41 @@
#import "startApp.h"
#import <Cordova/CDV.h>
@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