Javascript 从Phonegap应用程序中调用canOpenUrl
因此,我的应用程序中集成了一些twitter,这有点问题——如果安装了该应用程序,twitter站点仍会在我的应用程序中启动 所以我想知道是否可以在Phonegap应用程序中执行以下操作:Javascript 从Phonegap应用程序中调用canOpenUrl,javascript,ios,cordova,Javascript,Ios,Cordova,因此,我的应用程序中集成了一些twitter,这有点问题——如果安装了该应用程序,twitter站点仍会在我的应用程序中启动 所以我想知道是否可以在Phonegap应用程序中执行以下操作: // check whether facebook is (likely to be) installed or not if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) { // Sa
// check whether facebook is (likely to be) installed or not
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
// Safe to launch the facebook app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/200538917420"]];
}
我目前获得的启动Twitter的代码是:
var then = (new Date()).getTime();
var msg = encodeURIComponent("My Message");
window.open('twitter://post?message='+msg);
setTimeout(function(){
var now = (new Date()).getTime();
if((now - then)<400){
window.open('http://twitter.com/?status='+msg, '_system');
}
},300);
var-then=(新日期()).getTime();
var msg=encodeURIComponent(“我的消息”);
打开窗户twitter://post?message="味精",;
setTimeout(函数(){
var now=(new Date()).getTime();
如果((现在-然后)我建议您使用以下解决方案之一
1.添加社交共享phonegap插件
或
2.将这行代码添加到@end之前的MainViewController.m中
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]){
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}