【发布时间】:2015-08-15 09:01:18
【问题描述】:
有人用 Facebook SDK 4.2.0 实现了健身课程的分享吗? 我有一个数组中的 CLLocation 对象的轨迹,并希望将其作为 Facebook 中的课程分享。显示持续时间和距离,但地图上没有轨迹。 这意味着,我的问题是实现 Fitness:metric:location 部分。 有什么帮助吗?
这是我的源代码,很简单。 我想要的只是添加更多位置来显示轨道。 但 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];
【问题讨论】:
-
使用
NSMutableDictionary代替NSDictionary是否有效?NSMutableDictionary应该允许非唯一键;目前尚不清楚 FBSDKShareOpenGraphObject 将如何处理采用子类而不是 NSDictionary 但它可能没问题 -
谢谢,伊吉。但与 NSMutableDictionary 相同,这也覆盖了 Fitness:metrics:location 条目。