ios - FBDialogs canPresentMessageDialogWithParams returns false -
i'm trying add facebook sdk ios version of app. login, logout, share, , request features working, i'm having difficulty getting messagedialog feature work. facebook app , facebook messenger app installed on devices. however, every time call 'fbdialog canpresentmessagedialogwithparams:params' returns false.
my guess feature doesn't work while app still in development mode, guess. know if message dialog works apps under development? or have ideas doing wrong?
i've included code in case i've made bone-headed mistakes. appreciated!
// check if facebook app installed , can present share dialog fblinkshareparams *params = [[fblinkshareparams alloc] init]; params.link = [nsurl urlwithstring:@"https://www.facebook.com/"]; params.name = @"flash bear"; params.caption = nil; params.picture = nil; params.linkdescription = @"i'm playing flash bear. why don't come join me?"; // if facebook messenger app installed , can present share dialog if ([fbdialogs canpresentmessagedialogwithparams:params]) { // present message dialog [fbdialogs presentmessagedialogwithparams:params clientstate:nil handler: ^(fbappcall *call, nsdictionary *results, nserror *error) { if(error) { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog(@"error messaging link: %@", error.description); } else { // success nslog(@"result %@", results); } }]; } else { // present feed dialog // put dialog parameters uialertview *message = [[uialertview alloc] initwithtitle:@"sorry!" message:@"there error connecting fb messenger. please make sure installed." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [message show]; }
i had same problem application.
i resolved checking active session state. if state active session other open need open session again.
for doing same use following code.
if([fbsession activesession].state != fbsessionstateopen){ bool result = [fbsession openactivesessionwithallowloginui:no]; if(result) { //do stuff here } }
best luck.
Comments
Post a Comment