2015-12-28 18 views

回答

0

Google share link支持兩個url參數:url爲目標url,hl爲語言代碼。

- (void)showGooglePlusShare:(NSURL*)shareURL { 

    // Construct the Google+ share URL 
    NSURLComponents* urlComponents = [[NSURLComponents alloc] 
          initWithString:@"https://plus.google.com/share"]; 
    urlComponents.queryItems = @[[[NSURLQueryItem alloc] 
              initWithName:@"url" 
              value:[shareURL absoluteString]]]; 
    NSURL* url = [urlComponents URL]; 

    if ([SFSafariViewController class]) { 
     // Open the URL in SFSafariViewController (iOS 9+) 
     SFSafariViewController* controller = [[SFSafariViewController alloc] 
                   initWithURL:url]; 
     controller.delegate = self; 
     [self presentViewController:controller animated:YES completion:nil]; 
    } else { 
     // Open the URL in the device's browser 
    [[UIApplication sharedApplication] openURL:url]; 
    } 
} 
+0

@Kurt Van den Branden你好我已經嘗試了上面的代碼,但它直接將我重定向到谷歌加個人資料頁面,我嘗試在桌面瀏覽器中粘貼相同的URL,它顯示我的帖子窗口。你能幫我解決問題嗎? –

相關問題