我制作了需要Google+的社交申请。我知道我可以打开Google+作为Safari的链接(这不是真正的用户友好,不得不切换应用程序只是为了发布一些东西)。此代码打开Safari的链接:
-(IBAction)Google+:(id)sender {
NSLog(@"Google+");
//The link will go to Stack Overflow Google+ Page
NSURL *GooglePlus = [NSURL URLWithString:@"https://plus.google.com/+StackExchange/posts"];
[[UIApplication sharedApplication] openURL:GooglePlus];
}
但是有没有办法检测是否安装了Google+应用程序并在那里打开应用程序(如果不是,则打开Safari的链接)。我感谢所有花时间阅读我的帖子的人(即使你没有):)
答案 0 :(得分:7)
现在,您可以使用下一个协议启动Google+应用:
gplus://
例如
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@ “gplus://”]];
<强> UPD:强> 因此,要在G +应用中启动任何页面,您只需要在gplus://上的URL中更改https://,例如,这将启动用户配置文件:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gplus://plus.google.com/u/0/105819873801211194735/"]];
答案 1 :(得分:1)
根据此post,无法在其他应用中运行应用,但可以启动任何注册URL Scheme
的应用。您应该检查Google+ Application
是否属于这种情况。
修改强> Google+似乎不在list上: - (
答案 2 :(得分:0)
在Xcode 6和Swift中,你可以写:
let gplusURL = "gplus://your url"
if UIApplication.sharedApplication().canOpenURL(NSURL.URLWithString(gplusURL)){
UIApplication.sharedApplication().openURL(NSURL.URLWithString(gplusURL))
}
else{
var alertView = UIAlertView()
alertView.addButtonWithTitle("OK")
alertView.title = "HEY"
alertView.message = "It seems Google Plus is not installed on your device"
alertView.delegate = self
alertView.show()