所以我在我的应用程序中有一些推特集成,而且有点儿错误 - 如果安装了应用程序,推特网站仍会在我的应用程序中启动。
所以我想知道是否可以在Phonegap应用程序中执行something like this:
// 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);
答案 0 :(得分:0)
我建议您使用其中一种解决方案。
1.添加社交分享手机插件
https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
OR
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];
}
}