【问题标题】:Open Google+ Application in Xcode 4.5在 Xcode 4.5 中打开 Google+ 应用程序
【发布时间】:2012-12-29 23:56:18
【问题描述】:

我制作了一个需要 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 的链接)。我感谢所有花时间阅读我的帖子的人(即使你没有):)

【问题讨论】:

标签: ios ios-simulator social-networking xcode4.5 google-plus


【解决方案1】:

现在您可以使用下一个协议启动 Google+ 应用:

gplus://

例如

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gplus://"]];

统一更新: 因此,要在 G+ 应用中启动任何页面,您只需在 gplus:// 的 URL 中更改 https://,例如这将启动用户配置文件:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"gplus://plus.google.com/u/0/105819873801211194735/"]];

【讨论】:

  • 你好ponf,我可以用用户名打开google plus app吗?就像如果我没有像 id 一样的 105819873801211194735。那我可以用名字打开google plus吗
【解决方案2】:

根据这个post,无法在另一个应用程序中运行应用程序,但可以启动任何注册URL Scheme 的应用程序。您应该检查Google+ Application 是否属于这种情况。

编辑 Google+ 似乎不在 list 上:-(

【讨论】:

  • 太糟糕了,他们没有任何 Google+ 支持(可能在 iOS 7 中:)
  • iOS 的版本无关紧要。这是 Google 必须添加到 Google+ 应用程序中的内容。他们可以随时这样做。
【解决方案3】:

在 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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-30
    • 1970-01-01
    • 2013-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-03
    • 2022-12-21
    相关资源
    最近更新 更多