gpt4 book ai didi

ios - 在 native iOS 应用程序中使用 Facebook SDK 邀请多个 friend

转载 作者:可可西里 更新时间:2023-11-01 05:06:36 25 4
gpt4 key购买 nike

我正在使用 FB SDK 允许用户邀请 friend 下载我的应用程序。当用户单击邀请按钮时,我正在创建一个 FB 请求。 Action 看起来像这样:

- (IBAction)inviteButtonPressed:(UIButton *)sender {
// create a dictionary for our dialog's parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity: 7];

// set the frictionless requests parameter to "1"
[params setObject: @"1" forKey:@"frictionless"];
[params setObject: @"Test Invite" forKey:@"title"];
[params setObject:appID forKey:@"app_id"];


[params setObject: @"Test" forKey: @"message"];
if([friendsToInvite count] != 0){

[params setObject:friendsToInvite forKey:@"to"];

NSLog(@"%@", params);
}

// show the request dialog
[facebook dialog:@"apprequests" andParams:params andDelegate: nil];

}

问题是我正在为@"to"属性的对象传递一组 friend (由用户选择)。这是 Facebook 库尝试解析 @"to"对象的方式(来自 Facebook 的代码):

        id fbid = [params objectForKey:@"to"];
if (fbid != nil) {
// if value parses as a json array expression get the list that way
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
id fbids = [parser objectWithString:fbid];
if (![fbids isKindOfClass:[NSArray class]]) {
// otherwise seperate by commas (handles the singleton case too)
fbids = [fbid componentsSeparatedByString:@","];
}
invisible = [self isFrictionlessEnabledForRecipients:fbids];
}

我的代码给我这个错误:

-[__NSArrayM UTF8String]: unrecognized selector sent to instance 0x1aea00
2012-05-08 01:48:29.958 shmob[2976:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM UTF8String]: unrecognized selector sent to instance 0x1aea00'

当我将单个应用程序 ID 硬编码到 @"to"对象中时,它起作用了!你知道我如何邀请 Facebook 好友列表吗?

最佳答案

找到修复:

我使用 componentsjoinedbystring 将数组转换为字符串,然后将该字符串设置为 @"to"属性的参数。像这样:

if([friendsToInvite count] != 0){

NSString * stringOfFriends = [friendsToInvite componentsJoinedByString:@","];

[params setObject:stringOfFriends forKey:@"to"];

NSLog(@"%@", params);
}

// show the request dialog
[facebook dialog:@"apprequests" andParams:params andDelegate: nil];

像魅力一样工作。

关于ios - 在 native iOS 应用程序中使用 Facebook SDK 邀请多个 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10493498/

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