简体   繁体   中英

Facebook fitness open graph story with map and route on Map

I am trying to create fitness run story. I am able to post the story with info of distance, duration, calories etc but not able to show map as endomondo, nike running, runkeeper apps are doing.

在此处输入图片说明

Nike+ running app show fitness run info

在此处输入图片说明

My App show run info :(

I also tried to create custom open graph story with new action and objects but that also not work for me. Does anyone have some idea how to do this in iOS or PHP side?

This is the code for create fitness run story with map & polyline on facebook.

    NSMutableDictionary *dictonary = [[NSMutableDictionary alloc] init];
    [dictonary setObject:@"fitness.course" forKey:@"og:type"];
    [dictonary setObject:@"Name which you want to share" forKey:@"og:title"];
    [dictonary setObject:@"A url which will be open on click" forKey:@"og:url"];
    [dictonary setObject:@"set description like you ran 5km in 40 min" forKey:@"og:description"];
    //duration of the activity
    [dictonary setObject:@"2400" forKey:@"fitness:duration:value"];
    //time unit, s stands for seconds
    [dictonary setObject:@"s" forKey:@"fitness:duration:units"];
    //distance of the activity
    [dictonary setObject:@"5" forKey:@"fitness:distance:value"];
    //distance unit in KM
    [dictonary setObject:@"km" forKey:@"fitness:distance:units"];
    //speed distance in meter / time in seconds
    [dictonary setObject:@(distance/speed) forKey:@"fitness:speed:value"];
    [dictonary setObject:@"m/s" forKey:@"fitness:speed:units"];
    //here adding lat lngs in the request for show map on facebook activity
    int i=0;
    for (NSDictionary *location in locationArray) {
        CLLocation *loc=[[CLLocation alloc] initWithDictionary:location];
        [dictonary setObject:[NSNumber numberWithDouble:loc.coordinate.latitude] forKey:[NSString stringWithFormat:@"fitness:metrics[%d]:location:latitude",i]];
        [dictonary setObject:[NSNumber numberWithDouble:loc.coordinate.longitude] forKey:[NSString stringWithFormat:@"fitness:metrics[%d]:location:longitude",i]];
        i++;
    }
    FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:dictonary];
    FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
    action.actionType = @"fitness.runs";
    [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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM