Facebook在iOS中打开具有大型课程对象的图形对象

有没有人用Facebook SDK 4.2.0实现健身课程的分享? 我有一个数组中CLLocation对象的跟踪,并希望在Facebook中分享这个作为一门课程。 显示持续时间和距离,但地图上没有曲目。 这意味着,我的问题是实现适应性:度量:位置部分。 有帮助吗?

这是我的源代码,非常简单。 我只想添加一些位置来显示曲目。 但是NSDictionary不允许对同一个键使用多个条目,因此无法将其添加到属性中。

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; NSDictionary *properties = @{ @"og:type": @"fitness.course", @"og:title": @"YapYap Track", @"og:description": @" ", @"fitness:duration:value": appDelegate.actEvent.nDurationInSeconds, @"fitness:duration:units": @"s", @"fitness:distance:value": [NSNumber numberWithDouble:appDelegate.actEvent.nTracklengthInMeter.doubleValue/1000.0], @"fitness:distance:units": @"km", @"fitness:speed:value": [NSNumber numberWithDouble:appDelegate.actEvent.nTracklengthInMeter.doubleValue/appDelegate.actEvent.nDurationInSeconds.doubleValue], @"fitness:speed:units": @"m/s", @"fitness:metrics:location:latitude": appDelegate.actEvent.lat, @"fitness:metrics:location:longitude": appDelegate.actEvent.lon, }; FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties]; FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init]; action.actionType = @"fitness.walks"; [action setObject:object forKey:@"fitness:course"]; FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init]; content.action = action; content.previewPropertyName = @"fitness:course"; [FBSDKShareDialog showFromViewController:self withContent:content delegate:self]; 

我遇到了这个问题,并设法解决它。 为此,我混合了2篇文章: – 您使用的位置模型https://developers.facebook.com/docs/opengraph/guides/fitness – 您输入多个点的方式(关于打开图形复杂对象的最后一段): https: //developers.facebook.com/docs/sharing/opengraph/ios

所以我在单词metrics之后定义了一个索引[i]并且它有效!

这是我的代码(在swift中,但它在目标C中应该是相同的):

 var properties: [String : AnyObject] = [ "og:type": "fitness.course", "og:title": "Run", "og:description": "Run", "fitness:duration:value": run.duration, "fitness:duration:units": "s", "fitness:distance:value": run.distance, "fitness:distance:units": "m", "fitness:speed:value": run.speed, "fitness:speed:units": "m/s" ]; var i = 0; for point in run.path { properties["fitness:metrics[\(i)]:location:latitude"] = point.latitude properties["fitness:metrics[\(i)]:location:longitude"] = point.longitude properties["fitness:metrics[\(i)]:location:altitude"] = point.altitude properties["fitness:metrics[\(i)]:timestamp"] = SRUtils.formatDate( NSDate(timeIntervalSinceReferenceDate: point.timestamp), format: "yyyy'-'MM'-'dd'T'HH':'mm'") i++; } let object = FBSDKShareOpenGraphObject(properties: properties);