Facebook チャットを実装するアプリケーションを作成しようとしています。私の知る限り、すべての XMPP を正しくセットアップしましたが、動作させることができません。
ユーザーがログインし、(経由でFBSession
) Facebook に認証された後、チャット サービスに接続しようとしました。XMPP の出番は次のとおりです。
-(void)connect
{
[self setupStream];
NSError *err;
[self.xmppStream connectWithTimeout:10.00 error:&err];
}
-(void)setupStream
{
_xmppStream = [[XMPPStream alloc] initWithFacebookAppId:FACEBOOK_APP_ID];
[self.xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
}
- (void)xmppStreamDidConnect:(XMPPStream *)sender {
NSError *error;
NSError *err;
[self.xmppStream secureConnection:&err];
bool authed = [self.xmppStream authenticateWithFacebookAccessToken: FBSession.activeSession.accessTokenData.accessToken error:&error];
NSLog(@"%@", err);
NSLog(@"%@", [self.xmppStream authenticationDate]);
NSLog(@"%d, %@", authed, error);
}
- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender {
NSLog(@"did authenticate");
[self goOnline];
}
上記を実行すると、すべてうまくいくように見えます:xmppStreamDidConnect
は少し待ってから呼び出され、authed
常に YES を返し、そのエラーは常にnull
です。
ただし、エラー Domain=XMPPStreamErrorDomain Code=1 "ストリームが接続されるまでお待ちください"secureConnection
が返されます。UserInfo=0xb23dc30 {NSLocalizedDescription=ストリームが接続されるまでお待ちください。} はauthenticationDate
常にnull
同様です。また、 を含め、他のデリゲート メソッドが呼び出されることはありませんxmppStreamDidAuthenticate
。私は何を間違っていますか?