ios - FBSDKShareDialog delegate not called -


i use latest facebook sdk ios platform.i use fbsdksharedialog share image facebook,the code can share image facebook.but want share result delegate.

- (void)sharedimage:(uiimage *) sharedimage  fromviewcontroller:(uiviewcontroller *) fromviewcontroller {     fbsdksharephoto *photo  = [[fbsdksharephoto alloc] init];     photo.image             = sharedimage;     photo.usergenerated     = yes;      fbsdksharephotocontent *content = [[fbsdksharephotocontent alloc] init];     content.photos = @[photo];      fbsdksharedialog *dialog = [[fbsdksharedialog alloc] init];     dialog.fromviewcontroller = fromviewcontroller;     dialog.sharecontent = content;     dialog.delegate = self;     dialog.mode = fbsdksharedialogmodesharesheet;     [dialog show]; } #pragma mark - fbsdksharingdelegate - (void)sharer:(id<fbsdksharing>)sharer didcompletewithresults:(nsdictionary *)results {  } - (void)sharer:(id<fbsdksharing>)sharer didfailwitherror:(nserror *)error {  } - (void)sharerdidcancel:(id<fbsdksharing>)sharer {  } 

also add suggest code in appdelegate.m

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     [[fbsdkapplicationdelegate sharedinstance] application:application                              didfinishlaunchingwithoptions:launchoptions];     return yes; } - (void)applicationdidbecomeactive:(uiapplication *)application {     [fbsdkappevents activateapp]; } - (bool)application:(uiapplication *)application             openurl:(nsurl *)url   sourceapplication:(nsstring *)sourceapplication          annotation:(id)annotation {     [[fbsdkapplicationdelegate sharedinstance] application:application                                                    openurl:url                                          sourceapplication:sourceapplication                                                 annotation:annotation]; } 

but fbsdksharingdelegate method has been never called.

you setting fromviewcontroller controller should delegate not object.below code working , delegate getting called

- (ibaction)facebookbuttonclick:(uibutton *)sender {     //    facebookshare *facebookshare = [[facebookshare alloc] init];     //    [facebookshare sharedimage:[uiimage imagenamed:@"facebook_share"]     //            fromviewcontroller:self];     fbsdksharephoto *photo  = [[fbsdksharephoto alloc] init];     photo.image             = [uiimage imagenamed:@"facebook_share"];     photo.usergenerated     = yes;      fbsdksharephotocontent *content = [[fbsdksharephotocontent alloc] init];     content.photos = @[photo];      fbsdksharedialog *dialog = [[fbsdksharedialog alloc] init];     dialog.fromviewcontroller = self;     dialog.delegate = self;     dialog.sharecontent = content;     dialog.mode = fbsdksharedialogmodesharesheet;     [dialog show]; }  //fbsdksharingdelegate - (void)sharer:(id<fbsdksharing>)sharer didcompletewithresults:(nsdictionary *)results {     nslog(@"completed"); }  - (void)sharer:(id<fbsdksharing>)sharer didfailwitherror:(nserror *)error {     nslog(@"fail %@",error.description); }  - (void)sharerdidcancel:(id<fbsdksharing>)sharer {     nslog(@"cancel"); } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -