ios - Share map on Facebook post as a graph object (Map Attachment) -
ios - Share map on Facebook post as a graph object (Map Attachment) -
i trying share facebook "story" has action called share, , object called "picture_location". "picture_location" has custom geopoint property called "location".
what want able show story on user's wall saying like:
username shared location of image using appname.
the problem not format of story, showing map attachment.
the map attachment should display marker show coordinates passed in "location" geo-point.
i have tried solve 3 or more hours without success.
so far have:
nsmutabledictionary<fbgraphobject> *opengraphobject = [fbgraphobject opengraphobjectforpostwithtype:@"*namespace*:picture_location" title:@"some title" image:nil url:nil description:nil]; opengraphobject[ @"location" ] = @{ @"latitude": self.imagelatitude, @"longitude": self.imagelongitude }; // imagelatitude , imagelongitude nsnumbers // create action id<fbopengraphaction> action = (id<fbopengraphaction>)[fbgraphobject graphobject]; // link object action [action setobject:opengraphobject forkey:@"picture_location"]; // check if facebook app installed , can nowadays share dialog fbopengraphactionparams *params = [[fbopengraphactionparams alloc] init]; params.action = action; params.actiontype = @"*namespace*:share"; // if facebook app installed , can nowadays share dialog if([fbdialogs canpresentsharedialogwithopengraphactionparams:params]) { // show share dialog [fbdialogs presentsharedialogwithopengraphaction:action actiontype:@"*namespace*:share" previewpropertyname:@"picture_location" handler:^(fbappcall *call, nsdictionary *results, nserror *error) { if(error) { // there error nslog([nsstring stringwithformat:@"error publishing story: %@", error.description]); } else { // success nslog(@"result %@", results); } }]; // if facebook app not installed , can't nowadays share dialog } else { // fallback goes here } but result facebook app opens up, right story text , title, blank image , no map.
edit: these similar questions solutions have tried no avail.
using facebook open graph story map attachment (geopoint) how define "geopoint" property in facebook sdk ios using facebook open graph story map attachment (geopoint)
the right way of solving how parameters sent. couldn't find official documentation ios @ least.
facebook automatically tag place when object has geopoint property if:
the story has selected map attachment instead of usual one. within map attachment options custom geopoint property selected in mark/pin field. you set "previewpropertyname" custom property most importantly: custom property has wrapped within "data" dictionary this:opengraphobject[@"data"] = @{@"location": @{@"latitude": self.imagelatitude, @"longitude": self.imagelongitude }};
example code:
nslog(@"sharing: facebook location share"); nsmutabledictionary<fbgraphobject> *opengraphobject = [fbgraphobject opengraphobjectforpostwithtype:@"*namespace*:location" title:@"location share" image:mapimage // 1 shown on preview share dialogue url:@"an url link to" description:@"a description"]; // key, custom properties must within dictionary called "data" opengraphobject[@"data"] = @{@"location": @{@"latitude": self.imagelatitude, @"longitude": self.imagelongitude }}; // create action id<fbopengraphaction> action = (id<fbopengraphaction>)[fbgraphobject graphobject]; // link object action [action setobject:opengraphobject forkey:@"location"]; // check if facebook app installed , can nowadays share dialog fbopengraphactionparams *params = [[fbopengraphactionparams alloc] init]; params.action = action; params.actiontype = @"*namespace*:put"; // if facebook app installed , can nowadays share dialog if([fbdialogs canpresentsharedialogwithopengraphactionparams:params]) { // show share dialog [fbdialogs presentsharedialogwithopengraphaction:action actiontype:@"*namespace*:put" previewpropertyname:@"location" handler:^(fbappcall *call, nsdictionary *results, nserror *error) { if(error) { // there error nslog(@"%@",[nsstring stringwithformat:@"error publishing story: %@", error.description]); } else { // success nslog(@"result %@", results); } }]; // if facebook app not installed , can't nowadays share dialog } else { // nowadays alert or utilize feed dialogue instead } ios facebook facebook-graph-api
Comments
Post a Comment