Detecting that a Google+ post was shared successfully from your iOS app

If you want to capture if a post was successfully shared, follow these steps:

  1. Call the GPPURLHandler's handleURL method from your app delegate's URL handler to process any post-sharing URLs.

    - (BOOL)application: (UIApplication *)application
                openURL: (NSURL *)url
      sourceApplication: (NSString *)sourceApplication
             annotation: (id)annotation {
     return [GPPURLHandler handleURL:url
                   sourceApplication:sourceApplication
                          annotation:annotation];
    }
    
  2. Declare that your view controller implements the GPPShareDelegate protocol:

    @interface GameViewController () <GPPShareDelegate>
    
  3. Before you open the share dialog, set your GPPShare's delegate.

    (IBAction) didTapShare: (id)sender {
      [GPPShare sharedInstance].delegate = self;
      id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] shareDialog];
    
      // Other sharing options might be defined here.
      [shareBuilder open];
    
    }
    
  4. Implement the finishedSharingWithError: method:

    - (void)finishedSharingWithError:(NSError *)error {
      NSString *text;
    
      if (!error) {
        text = @"Success";
      } else if (error.code == kGPPErrorShareboxCanceled) {
        text = @"Canceled";
      } else {
        text = [NSString stringWithFormat:@"Error (%@)", [error localizedDescription]];
      }
    
      NSLog(@"Status: %@", text);
    }
    

Your app must follow the Google+ developer policies and terms of service, including how your app might use this feature to incentivize sharing.

Send feedback about...

Google+ Platform for iOS
Google+ Platform for iOS