ios - 如何在 iOS 应用程序中配置 XMPP Facebook 聊天
<p><p>我正在开发一个使用 Facebook 聊天功能的 iOS 应用程序。 </p>
<p>(我使用的是 Robbie Hanson 的 XMPPFramework)。</p>
<p> <a href="https://github.com/robbiehanson/XMPPFramework" rel="noreferrer noopener nofollow">https://github.com/robbiehanson/XMPPFramework</a> </p>
<p>在连接方法中我已经给出了我的用户名和密码</p>
<pre><code>- (BOOL)connect
{
if (!) {
return YES;
}
NSString *myJID = [ stringForKey:kXMPPmyJID];
NSString *myPassword = [ stringForKey:kXMPPmyPassword];
//
// If you don't want to use the Settings view to set the JID,
// uncomment the section below to hard code a JID and password.
//
myJID = @"[email protected]";
myPassword = @"Mypassword";
if (myJID == nil || myPassword == nil) {
return NO;
}
];
password = myPassword;
NSError *error = nil;
if (!)
{
UIAlertView *alertView = [ initWithTitle:@"Error connecting"
message:@"See console for error details."
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
;
DDLogError(@"Error connecting: %@", error);
return NO;
}
</code></pre>
<p>在上游方法中我已经给出了我的主机名和端口号</p>
<pre><code>- (void)setupStream
{
NSAssert(xmppStream == nil, @"Method setupStream invoked multiple times");
xmppStream = [ init];
#if !TARGET_IPHONE_SIMULATOR
{
xmppStream.enableBackgroundingOnSocket = YES;
}
#endif
xmppReconnect = [ init];
xmppRosterStorage = [ init];
xmppRoster = [ initWithRosterStorage:xmppRosterStorage];
xmppRoster.autoFetchRoster = YES;
xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;
xmppvCardStorage = ;
xmppvCardTempModule = [ initWithvCardStorage:xmppvCardStorage];
xmppvCardAvatarModule = [ initWithvCardTempModule:xmppvCardTempModule];
xmppCapabilitiesStorage = ;
xmppCapabilities = [ initWithCapabilitiesStorage:xmppCapabilitiesStorage];
xmppCapabilities.autoFetchHashedCapabilities = YES;
xmppCapabilities.autoFetchNonHashedCapabilities = NO;
// Activate xmpp modules
;
;
;
;
;
// Add ourself as a delegate to anything we may be interested in
;
;
;
;
// You may need to alter these settings depending on the server you're connecting to
allowSelfSignedCertificates = NO;
allowSSLHostNameMismatch = NO;
}
</code></pre>
<p>有没有我遗漏的步骤?我不知道如何进一步进行。如果有人知道解决方案,请帮助我。请帮帮我
提前致谢。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>尝试使用以下方法保护连接:</p>
<pre><code>;
</code></pre>
<p>在</p>
<pre><code> - (void)xmppStreamDidConnect:(XMPPStream *)sender;
</code></pre>
<p>委托(delegate)方法。</p>
<p>希望对你有帮助。</p></p>
<p style="font-size: 20px;">关于ios - 如何在 iOS 应用程序中配置 XMPP Facebook 聊天,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22660989/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22660989/
</a>
</p>
页:
[1]