mirror of
https://github.com/lampaa/com.lampa.startapp.git
synced 2026-05-20 00:01:31 +08:00
@@ -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
@@ -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>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
@interface startApp : CDVPlugin
|
||||
|
||||
- (void)check:(CDVInvokedUrlCommand*)command;
|
||||
- (void)start:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user