Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone App - Google plus share with pre-fill text

Tags:

ios

iphone

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?

like image 671
Jean Avatar asked Sep 20 '12 08:09

Jean


2 Answers

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;
  }

  // ...
}
like image 122
James McCracken Avatar answered Oct 27 '22 01:10

James McCracken


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

  • Google+, as opposed to e. g. Twitter, does not allow any query parameters beside "url" for the URL and "hl" for the language code. (Source: Documentation on developers.google.com)
  • Google+ uses meta-information supplied via the schema.org microdata-format to decide which part of the content to use. (Source: This German blog article on the same topic)

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

like image 20
I'm with Monica Avatar answered Oct 27 '22 00:10

I'm with Monica