Sharing images and videos to Google+ from your iOS app

When you use the native share dialog, which requires Google+ Sign-In, you can attach images and videos to posts that are shared from your app.

Sharing an image

To share an image, you set up your share dialog builder and call the attachImage method and provide the path to the image:

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

  // Set any prefilled text that you might want to suggest
  [shareBuilder setPrefillText:@"Achievement unlocked! I just scored 99 points. Can you beat me?"]

  NSString *fileName = @"samplemedia1";
  [shareBuilder attachImage:[UIImage imageNamed:fileName];

  [shareBuilder open];
}

Sharing a video

To share a video, you set up your share dialog builder and call the attachVideoURL method and provide a URL to the video, which can be a local resource:

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

  // Set any prefilled text that you might want to suggest
  [shareBuilder setPrefillText:@"Achievement unlocked! I just scored 99 points. Can you beat me?"]

  NSString *fileName = @"samplevideo";
  NSString *extension = @"mov";
  NSURL *filePath = [[NSBundle mainBundle] URLForResource:fileName withExtension:extension];
  [shareBuilder attachVideoURL:filePath];

  [shareBuilder open];
}

Send feedback about...

Google+ Platform for iOS
Google+ Platform for iOS