XMPPFramework/iOS issue: send and receive subscription - ios

I have a challenge with XMPPFramework today...
I've configured ejabberd correctly: server is up and running and registering users correctly by in-band registration.
But when I try to send a subscription request from one device, the second one can't recieve the presence for the first one. Here's the code I use on the first device to subscribe to a user, as documented:
[[[self appDelegate] xmppRoster] addUser:userJID withNickname:nickname groups:nil subscribeToPresence:YES];
And if everything goes ok, the second device must fire the delegate method:
- (void)xmppRoster:(XMPPRoster *)sender didReceiveBuddyRequest:(XMPPPresence *)presence
The problem is that this delegate method is never fired.
The server creates the new contact for the user, I can see it on ejabberd web administrator, but the subscription type is set to none.
Any ideas?
UPDATE:
Well, it seems that I was forgetting to include the hostname into the JID. Now, the delegates for XMPPRoster are not being called, but I can see on ejabberd that the request is not 'none' but 'both' and pending validation.
Can't imagine why the XMPPRoster delegates are not firing... it seems that ejabberd server don't send the proper notification when a user receives a new subscription request...

It seems that eJabberd was misconfigured or something. Just installed OpenFire and everything works correctly.

Related

Delegate methods for typing indicator on Twilio chat not being called

Working on a Swift chat application.
On one device, I join a channel with unique name "private:chat", and then I call channel.typing() on the channel (as is mention in docs).
On another device, I again create a client with a delegate set to self:
TwilioChatClient.chatClient(withToken: token, properties: nil, delegate: self) { (result, chatClient) in
self.client = chatClient
}
And then I implemented typingStartedOn delegate method to listen to typing on the channel.
func chatClient(_ client: TwilioChatClient, typingStartedOn channel: TCHChannel, member: TCHMember) {
print(">>>>>>>>>>>>> typing on \(channel.uniqueName) by \(member.identity)")
}
However, the delegate method does not get called, even though I confirmed that the channel.typing() gets called by the other account on the other device. The docs inline code in JS, but based on iOS chat demo app I came to conclusion that in Swift the delegate methods are the way to go.
Any idea what might be going on here?
EDIT: Some (haven't tested all) of the other delegate methods, such as synchronizationStatusUpdated, are getting called.
So after all, the issue was not in the iOS client, but in our implementation of the access token server.
As #rbeiter noted in his comment on GitHub issue, Twilio does not send typing indicator if the user identity is the same on both devices. I was setting the identity properly on both devices to keep it different, but our access token server ignored the identity parameter and used a hardcoded value. Thus from Twilio viewpoint, the same user was on both devices. Fixing the access token server fixed the problem.

Token expiration in Twilio

I'm working on embedding a soft phone into a web page that will go into Odoo (web based ERP system). It will allow inbound and outbound calls for employees.
The token expires every hour. So this means the user will have to refresh the page every hour. I could do an http refresh but if the user is on a call when it does the refresh it will knock them off the call.
How do we get around this so we can build a fully working dialer?
Twilio evangelist here.
I'd suggest using JavaScript to do an asynchronous HTTP request to get a new token from your server and then updating the instance of client with it.
Hope that helps.
Another Twilio evangelist here!
You can actually listen for the offline event on the Twilio.Device object. From the documentation:
.offline( handler(device) )
Register a handler function to be called when the offline event is
fired. This is triggered when the connection to Twilio drops or the
device's capability token is invalid/expired. In either of these
scenarios, the device cannot receive incoming connections or make
outgoing connections. If the token expires during an active connection
the offline event handler will be called, but the connection will not
be terminated. In this situation you will have to call
Twilio.Device.setup() with a valid token before attempting or
receiving the next connection.
So you want something like:
Twilio.Device.offline(function(device) {
fetchTokenFromServer(function(token) {
device.setup(token);
});
});
where fetchTokenFromServer makes the HTTP request that Devin suggested in his answer.
Let me know if this helps.
I just ran into this issue so hopefully my solution can help you and others.
I was using twilio.js v1.3 and tried implementing my offline callback like #philnash recommended, but kept getting the error device.setup is not a function. I then tried using Twilio.Device.setup(newToken) and was able to get the capability token refreshed but also ended up getting a new error: Cannot read property 'setToken' of undefined.
I ended up having to use twilio.js v1.4 to make the error go away. My working solution looks like this:
Twilio.Device.offline(function(device) {
$.ajax(urlToGetNewToken, type: 'get').done(function(newToken) {
Twilio.Device.setup(newToken)
})
})

Sinch Client works but messages aren't being sent

I'm using sinch and I've gotten the client to work by registering a user, but I can't send a message. When I click my send button, nothing happens. The required methods that need to be implemented, such as messageFailed(), messageDelivered(), etc. are not being called either. Does anyone know why?
Have you registered the one more user? Can you enable logging and share the full log output.
See comment below, user tried to send message to self

MUC implemention on ejabberd server using xmppFramework

I want to know that is it possible to create a chatroom and invite people ? I have setup ejabberd on my mac and implemented chat with single buddy following
this link but i want to implement MUC. I tried demo project of MUC which come with xmppframework available here ,but every time i get error 404 remote server not found. The delegate method
- (void)xmppRoomDidCreate:(XMPPRoom *)sender;
never gets called.
Instead
- (void)handleDidLeaveRoom:(XMPPRoom *)room
this method gets called. Has anyone successfully implemented MUC using localhost as server?If yes then please let me know the XMPP client you are using , because for ejabberd,it says remote server not found.
Did you try with conference.host (presumably conference.localhost) as MUC host ?

XMPPFramework: Sending a message with timeout

I'm using XMPPFramework in my iOS app to send and receive command messages between client and server. The server would answer to different command messages immediately.
Sometime the connection is very slow, the message sent from client would have no response for a long time. So I want to know how can I send an XMPP message with timeout or I have to implement this myself.
Anyway:
This goes to - (void)xmppStream:(XMPPStream *)sender didSendMessage:(XMPPMessage *)message.
Using Reachability, the internet is still reachable via [[Reachability reachabilityForInternetConnection] isReachable].
Why not just set a timer when you send the message, override the response callback on the XMPPStream, and see which is called first?

Resources