gpt4 book ai didi

ios - 对象在 iOS 的 Open Graph 共享对话框中消失

转载 作者:行者123 更新时间:2023-11-29 10:46:22 24 4
gpt4 key购买 nike

我正在尝试通过开放图分享对话为未通过 Facebook 登录的用户分享自定义故事。我的代码大部分是直接取自 Facebook 的示例,并进行了一些更改,因为我们没有任何图像。这似乎最初有效。应用程序切换到 Facebook,并显示格式正确的预览。但是,随后预览消失并且“发布”按钮变灰。用户除了取消并返回我们的应用程序外别无选择。我还仔细检查了所有属性和 namespace 。

NSString *urlDeepLink = [NSString stringWithFormat:@"http://www.appname.com?dropSpot='%@'&user='%@'&name='%@'&lat=%f&long=%f&rad=%d",place.objectId, [User currentUser].objectId, geospot.name, geospot.location.latitude, geospot.location.longitude, geospot.radius];

NSMutableDictionary<FBGraphObject> *object = [FBGraphObject openGraphActionForPost];
object[@"type"] = @"appname:action";
object[@"title"] = geospot.name;
object[@"description"] = place.detail;
object[@"url"] = urlDeepLink;

NSString *lat = [[NSNumber numberWithDouble:geospot.location.latitude]stringValue];
NSString *lng = [[NSNumber numberWithDouble:geospot.location.longitude]stringValue];

object[@"data" ] = @{ @"location": @{ @"latitude": lat, @"longitude": lng }};
object[@"fbsdk:create_object"] = @YES;

// create an Open Graph action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:object forKey:@"action"];

// add expiration date for correct story tenses
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH:mm:ssZ"];
action[@"end_time"] = [dateFormatter stringFromDate:[NSDate date]];


// Check if the Facebook app is installed and we can present the share dialog
FBOpenGraphActionShareDialogParams *params = [[FBOpenGraphActionShareDialogParams alloc] init];
params.action = action;
params.actionType = @"appname:set";

// If the Facebook app is installed and we can present the share dialog
if([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]) {
// Show the share dialog
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:@"appname:set"
previewPropertyName:@"action"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// There was an error
NSLog([NSString stringWithFormat:@"Error publishing story: %@", error.description]);
} else {
// Success
NSLog(@"result %@", results);
}
}];

// If the Facebook app is NOT installed and we can't present the share dialog
} else {
// FALLBACK: publish just a link using the Feed dialog
// Put together the dialog parameters

UIAlertView *alertUnableToPost = [[UIAlertView alloc]initWithTitle:@"Coudn't Post" message:@"We were unable to post your status to Facebook. This could be because you don't have the Facebook app installed on your phone." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertUnableToPost show];

NSLog(@"Coudn't present share dialogue");
}

最佳答案

我明确地将“结束时间”设置为当前日期(残留代码!)。删除该行可以使其正常工作。

关于ios - 对象在 iOS 的 Open Graph 共享对话框中消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22233602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com