简体   繁体   中英

How to use expires_in in Facebook v4.0 iOS SDK with an Open Graph action?

I have been migrating to Facebook SDK v4.x to implement an Open Graph story and so far it's been fine, but the problem that I am having is that I used to add a property for the action called "expires_in".

The thing is that I don't really know how to do that with new SDK.

The code that I am using is identical from the tutorial, like this:

FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"books.reads";
[action setObject:object forKey:@"books:book"];

I assumed that I needed to do the following:

[action setObject:30 forKey:@"expires_in"];

but the "setObject" parameter requires an object of type FBSDKShareOpenGraphObject, which I don't know exactly which parameters will it should get. For example, should I create the object like this?

NSDictionary *properties = @{
    @"expires_in": @"30",
};

FBSDKShareOpenGraphObject *expires_in_object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

Ok, I got it working.

I said in a comment above that it didn't work out with setNumber:forKey but it finally worked. This is what I use:

[action setNumber:[NSNumber numberWithInt:300] forKey:@"expires_in"];

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