Google+ Platform for iOS

Sharing prefilled posts to Google+ from your iOS app

You can prefill the posts on behalf of your users with prefilled post text, thumbnail and title, or recipients. The text and recipients are suggestions that the user can customize before they share to Google+. The prefilled thumbnail and title look similar to sharing a URL but are useful when you do not have a URL to represent what the user might want to share. You might also consider attaching media to a post instead of using the thumbnail and title approach.

Prefill the post text

You can suggest text for the user to share by prefilling the post text to help the user create a quality post that will drive engagement. For example, you might include a hashtag in your prefilled text that can help other users find the post.

- (IBAction) didTapShare: (id)sender {
  id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
  // Or use the basic share, which does not require using Google+ Sign-In:
  // id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];

  // Set any prefilled text that you might want to suggest
  [shareBuilder setPrefillText:@"Just finished an awesome 3.7 mile hike! Check out my pictures. #hiking"];

  [shareBuilder setURLToShare:[NSURL URLWithString:@"https://www.example.com/albums/sf/1234567/"]];
  [shareBuilder setContentDeepLinkID:@"/albums/sf/1234567"];

  [shareBuilder open];
}

This example uses both prefilled text and shares a URL that also has a deep link attached to additionally help drive traffic to the mobile version of the app.

Prefill the recipients of a post

When you share to Google+, your users will have the option to choose who should receive this post from a list of their Google contacts and their Google+ circles. This list is presented to them along with suggestions of the people they interact with most. In addition, users can choose to share with their device contacts by searching for them. To use this feature, simply make sure you are using the latest SDK and the feature will be automatically enabled.

You can also manage these suggestions on your own by constructing a list of suggested recipients. When you use Google+ Sign-In, you can prefill up to 10 individuals to suggest to the user who to share the post with. The prefilled recipients is an array of Google+ user IDs or email addresses.

Your app, if it uses Google+ Sign-In, can load the user's list of friends that the user chose to make visible to your app. You might use this list of people to suggest recipients for the shared post.

The following example demonstrates how to prefill multiple recipients by passing an array of Google+ user IDs to the setPreselectedPeopleIDs method:

- (IBAction) didTapShare: (id)sender {
  id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];

  // Set any prefilled text that you might want to suggest
  [shareBuilder setPrefillText:@"I just found this awesome app that I think you would like!"];

  [shareBuilder setURLToShare:[NSURL URLWithString:@"https://play.google.com/store/apps/details?id=com.google.android.apps.plus"]];

  
  [shareBuilder setPreselectedPeopleIDs:@[@"106189723444098348646",@"109813896768294978296"]];

  [shareBuilder open];
}

Prefill the thumbnail and title in a post

If your application does not have a web presence, you can manually set the title, description, and thumbnail URL by using the setTitle:description:thumbnailURL method. You must also specify a deep-link identifier to direct mobile users to the correct context in your app.

- (IBAction) didTapShare: (id)sender {
  id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];

  // This line will manually fill out the title, description, and thumbnail of the
  // item you're sharing.
  [shareBuilder setTitle:@"New 5k record!"
             description:@"I just ran 5000 meters in 26:16! That's a new record!"
            thumbnailURL:[NSURL URLWithString:@"https://www.example.com/images/5krun.png"]];
  [shareBuilder setContentDeepLinkID:@"/races/sf/1234567"];
  [shareBuilder open];
}

If you call both setUrlToShare and setTitle:description:thumbnailURL, the content that is generated from the setUrlToShare method overwrites the content that is defined in the setTitle:description:thumbnailURL method.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.