gpt4 book ai didi

iphone - 为什么我无法在我的 iOS 应用程序中对 Facebook Chat 进行身份验证?

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

我一直在网上搜索,试图找到解决这个问题的方法。我了解它应该如何工作的基本思想,但我无法让实现工作,也找不到任何像样的例子来帮助我。到目前为止,我已经能够使用 iOS 6 身份验证机制成功登录用户,但我不知道如何从那里向 Jabber 服务器验证用户身份。这是我所拥有的:

用户登录后调用connect

-(void)connect
{
[self setupStream];
NSError *error = nil;
[_xmppStream authenticateWithFacebookAccessToken: FBSession.activeSession.accessTokenData.accessToken error:&error];
NSLog(@"%@", error);
[NSString stringWithFormat:@"%@", self];
}

-(void)newSetupStream
{
_xmppStream = [[XMPPStream alloc] initWithFacebookAppId:@"611051652253156"];

#if !TARGET_IPHONE_SIMULATOR
{
xmppStream.enableBackgroundingOnSocket = YES;
}
#endif


_xmppReconnect = [[XMPPReconnect alloc] init];


_xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init];

_xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:_xmppRosterStorage];
_xmppRoster.autoFetchRoster = YES;
_xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;


_xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
_xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:_xmppvCardStorage];
_xmppvCardAvatarModule = [[XMPPvCardAvatarModule alloc] initWithvCardTempModule:_xmppvCardTempModule];


_xmppCapabilitiesStorage = [XMPPCapabilitiesCoreDataStorage sharedInstance];
_xmppCapabilities = [[XMPPCapabilities alloc] initWithCapabilitiesStorage:_xmppCapabilitiesStorage];
_xmppCapabilities.autoFetchHashedCapabilities = YES;
_xmppCapabilities.autoFetchNonHashedCapabilities = NO;


[_xmppReconnect activate:_xmppStream];
[_xmppRoster activate:_xmppStream];
[_xmppvCardTempModule activate:_xmppStream];
[_xmppvCardAvatarModule activate:_xmppStream];
[_xmppCapabilities activate:_xmppStream];


[_xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[_xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
}

无论我尝试什么,它总是返回相同的错误:Error Domain=XMPPStreamErrorDomain Code=4 "The server does not support X-FACEBOOK-PLATFORM authentication."

我对 XMPP 或 Facebook API 都不太熟悉,所以我确定我缺少一些简单的东西,但我一直在努力解决这个问题,但无法取得任何进展。有什么想法吗?

最佳答案

我找到了答案。以防其他人遇到同样的问题:我实际上从未告诉我的 XMPPStream 进行连接。我之前尝试过所有连接方法,但它们从未奏效。我现在意识到我根本没有等到他们完成连接。这是我最终更改的内容:

NSError *error;
NSError *err;
[_xmppStream connectWithTimeout:10.00 error:&err];

[_xmppStream authenticateWithFacebookAccessToken: FBSession.activeSession.accessTokenData.accessToken error:&error];
while (error)
{
sleep(1);
[_xmppStream authenticateWithFacebookAccessToken: FBSession.activeSession.accessTokenData.accessToken error:&error];
}

我意识到这不是最优雅的解决方案,但它确实有效。

关于iphone - 为什么我无法在我的 iOS 应用程序中对 Facebook Chat 进行身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17123425/

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