简体   繁体   中英

iPhone App - Google plus share with pre-fill text

I heard we can use this link to share on Google+ https://plus.google.com/share?url=YOUR_URL_HERE

How do we add a text to the 'share/post'? (like in Twitter, I can set the 'prefilled text' parameter) What is the URL parameter for it? Can someone help please?

If you want to tightly integrate your app with Google+ I would recommend using their SDK outlined here: https://developers.google.com/+/mobile/ios/

The bit on sharing: https://developers.google.com/+/mobile/ios/#share_on_google

Create your share object:

GooglePlusShare *share =
    [[[GooglePlusShare alloc] initWithClientID:clientID] autorelease];
share.delegate = self; // optional
appDelegate.share = share; //optional

In your button's IBAction:

- (IBAction) didTapShare: (id)sender {
  // Add code here to retrieve the value of "share"
  // This could be self.share if this is a property of your ViewController
  // or ((MyAppDelegate *)[[UIApplication sharedApplication] delegate]).share

  [[[[share shareDialog]
      setURLToShare:[NSURL URLWithString:@"URL_TO_SHARE"]]
          setPrefillText:@"YOUR TEXT HERE"] open];

  // Or, without a URL or prefill text:
  [[share shareDialog] open];
}

Google+ URL handler:

- (BOOL)application: (UIApplication *)application
              openURL: (NSURL *)url
    sourceApplication: (NSString *)sourceApplication
           annotation: (id)annotation {
  // ...

  if ([self.share handleURL:url
          sourceApplication:sourceApplication
                 annotation:annotation]) {
    return YES;
  }

  // ...
}

I've done a little research and came up with this:

That said, you should be able to influence the content of the +1-share-thingy if you control the shared page. If not, there still seems no way to do this.

Also: This question seems to be an almost exact duplicate of this question asked 2012-02-26 by Vitali Ponomar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM