Creating a facebook custom story containing a map with a path (iOS example)

211 views Asked by At

In order to draw a path inside a fb custom story with a map, how am I supposed to write the array of GeoPoints? Unfortunately the fb documentation seems not to be very detailed about this topic.

Let's have a custom story with 'test' namespace containing an 'object' which inherits from Place. 'object' has a 'route' property which is an array of GeoPoints.

NSDictionary *properties =
    @{@"og:type":@"test:object",
      @"og:title":@"Title",
      @"object:route":
       @[@{@"latitude":@37.782600, @"longitude":@-122.443265},
         @{@"latitude":@37.785992, @"longitude":@-122.404813}]};

FBSDKShareOpenGraphObject *obj = [FBSDKShareOpenGraphObject objectWithProperties:properties];
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"test:action" object:obj key:@"object"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"object";

[FBSDKShareDialog showFromViewController:self withContent:content delegate:self];

With this code I get an exception as the SDK expects latitude and longitude to have a namespace. I've tried both "og:latitude" and "test:longitude" but I always get an blank map with no path.

1

There are 1 answers

0
Javier de la Cueva On

That's normally used by Sport based Apps. There are special og tags for it. Please check out this docs: https://developers.facebook.com/docs/opengraph/guides/fitness

You can use fitness:metrics like this:

  • "fitness:metrics:location:latitude"
  • "fitness:metrics:location:longitude"

You can send an as many as you need in order to create the path.

As a tip, you can use an App like Runkeeper, Strava, Endomondo, etc... and share a story. Then you can just get the URL and use Facebook Debugger to see og:tags:

https://developers.facebook.com/tools/debug

I hope it helps.