ios - Want to perform some action only when the post is successful via UIActivityViewController in iPhone -


i having app in using uiactivityviewcontroller.

this code using.

 nsstring *posttext = @"my text";     nsarray *activityitems = @[posttext];      uiactivityviewcontroller *activitycontroller =     [[uiactivityviewcontroller alloc]      initwithactivityitems:activityitems applicationactivities:nil];     activitycontroller.excludedactivitytypes = [nsarray arraywithobjects:uiactivitytypeprint, uiactivitytypecopytopasteboard, uiactivitytypeassigntocontact, uiactivitytypesavetocameraroll, nil];     [self presentviewcontroller:activitycontroller                        animated:yes completion:nil]; 

this works fine. when open twitter or e-mail uiactivityviewcontroller, shows text want share , fine.

but ,now want perform action in db when post successful or e-mail sent successfully.

how can that?

    [activitycontroller setcompletionhandler:^(nsstring *act, bool done)              {                   nslog(@"act type %@",act);                  nsstring *servicemsg = nil;                  if ( [act isequaltostring:uiactivitytypemail] )           servicemsg = @"mail sent";                  if ( [act isequaltostring:uiactivitytypeposttotwitter] )  servicemsg = @"post on twitter, ok!";                  if ( [act isequaltostring:uiactivitytypeposttofacebook] ) servicemsg = @"post on facebook, ok!";                   if ( done )                  {                      uialertview *alert = [[uialertview alloc] initwithtitle:servicemsg message:@"" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil];                      [alert show];                      [alert release];                  }                  else                  {                       // didn't succeed.                   }              }]; 

use completion handler's "done" parameter check if completed or not


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -