quickblox accepting video chat call issue - chat

i am Using Quickblox for making video calls in my app.
I was able to successfully make a call, and to receive a new session. but have a problem on receiving remote video track. after accepting the session.
I am not sure if the problem is in the accepting the call, or not receiving the remote video track. I am having the error below in my log:
2015-12-03 23:15:22:005 New Video Chat Project[4680:1226691] rtc:: Set SDP with error: Error Domain=RTCSDPError Code=-1 "(null)" UserInfo={error=Failed to set remote offer sdp: Called in wrong state: STATE_SENTOFFER},
please let me know what you think.

The Error stated above, pointing out that the call has been created more the once. Check you call methods if you have such Log. Thank you

You could become not sent to local video to opponent.
You start local camera firstly.
self.cameraCapture = [[QBRTCCameraCapture alloc] initWithVideoFormat:[QBRTCVideoFormat defaultFormat] position:AVCaptureDevicePositionFront];
[self.cameraCapture startSession];
After that,you have to modify your delegate method.
- (void)session:(QBRTCSession *)session initializedLocalMediaStream:(QBRTCMediaStream *)mediaStream {
session.localMediaStream.videoTrack.videoCapture = self.cameraCapture; }
I hope it helps you.

Related

Error handling in firebase-database connection

I am trying to check for errors while the app is trying to connect to the firebase-realtime-database.
My main concern is when the user fires up the app for the first time, but with no internet connection. I create the ref to the database and try to observe a single event, but the console log starts to throw error messages and none of them is captured by my code.
//------- variable declaration
var ref:DatabaseReference?
//------- inside de method
ref = Database.database().reference(withPath: "myPath")
ref?.observeSingleEvent(of: .value, with: { (snapshot) in
//I cannot even fire up the observer, so I never get here
}){(error) in
//no error is captured here also
}
Even if I comment or delete the observeSingleEvent I can see the errors getting thrown in the console, but I would like to capture them.
Does anyone know how to do that?
Thanks in advance
It is not an "error" to be offline at the time of a query. The SDK will continue trying to make the request for as along as your app is running and your code has an observer attached at that location.
If you want to detect the connection state, you can attach an observer at /.info/connected to get a callback that indicates the current state of the connection. Note that this information might be out of date, as a stalled connection doesn't immediately become fully disconnected until after a while.

How to detect absent network connection when setting Firestore document

We are building a real-time chat app using Firestore. We need to handle a situation when Internet connection is absent. Basic message sending code looks like this
let newMsgRef = database.document(“/users/\(userId)/messages/\(docId)“)
newMsgRef.setData(payload) { err in
if let error = err {
// handle error
} else {
// handle OK
}
}
When device is connected, everything is working OK. When device is not connected, the callback is not called, and we don't get the error status.
When device goes back online, the record appears in the database and callback triggers, however this solution is not acceptable for us, because in the meantime application could have been terminated and then we will never get the callback and be able to set the status of the message as sent.
We thought that disabling offline persistence (which is on by default) would make it trigger the failure callback immediately, but unexpectedly - it does not.
We also tried to add a timeout after which the send operation would be considered failed, but there is no way to cancel message delivery when the device is back online, as Firestore uses its queue, and that causes more confusion because message is delivered on receiver’s side, while I can’t handle that on sender’s side.
If we could decrease the timeout - it could be a good solution - we would quickly get a success/failure state, but Firebase doesn’t provide such a setting.
A built-in offline cache could be another option, I could treat all writes as successful and rely on Firestore sync mechanism, but if the application was terminated during the offline, message is not delivered.
Ultimately we need a consistent feedback mechanism which would trigger a callback, or provide a way to monitor the message in the queue etc. - so we know for sure that the message has or has not been sent, and when that happened.
The completion callbacks for Firestore are only called when the data has been written (or rejected) on the server. There is no callback for when there is no network connection, as this is considered a normal condition for the Firestore SDK.
Your best option is to detect whether there is a network connection in another way, and then update your UI accordingly. Some relevant search results:
Check for internet connection with Swift
How to check for an active Internet connection on iOS or macOS?
Check for internet connection availability in Swift
As an alternatively, you can check use Firestore's built-in metadata to determine whether messages have been delivered. As shown in the documentation on events for local changes:
Retrieved documents have a metadata.hasPendingWrites property that indicates whether the document has local changes that haven't been written to the backend yet. You can use this property to determine the source of events received by your snapshot listener:
db.collection("cities").document("SF")
.addSnapshotListener { documentSnapshot, error in
guard let document = documentSnapshot else {
print("Error fetching document: \(error!)")
return
}
let source = document.metadata.hasPendingWrites ? "Local" : "Server"
print("\(source) data: \(document.data() ?? [:])")
}
With this you can also show the message correctly in the UI

Execute code within Apple Keynote

I'm trying to send some code to a remote server everytime I change a slide on Keynote. Is this possible? Can I add code to be executed on keynote?
Basically, everytime a user changes a slide, it sends a POST request to a server with a string as a parameter.
Thank you!

Detecting when a user leaves or enters a channel with hubot

I am trying to make Hubot detect when a user enters or leaves a channel, but so far I have been unable to actually find ANY information pertaining to this.
Does anyone have any ideas of how to do this? :)
Thanks in advance!
Hubot's Robot class has functions enter and leave that will fire a callback you give when any user enters or leaves the room. That callback takes a Response, which has a property message of type Message, which in turn has a property user of type User.
module.exports = (robot) ->
robot.enter (response) ->
# at this point you can get the user's name with:
# response.message.user.name
# works the same for robot.leave
However, it appears that the IRC adapter for hubot doesn't currently fire the messages needed to get those functions to work.

Checking SMS sending status iPhone

It's possible to check SMS sending status? e.g.
MFMessageComposeViewController * smsPicker = [[MFMessageComposeViewController alloc] init];
smsPicker.messageComposeDelegate = self;
smsPicker.body = #"Body";
[self presentModalViewController:smsPicker animated:YES];
[smsPicker release];
I don't know why, but the delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result; executing before sending and works if user cancelled SMS.
And I need to know, if SMS sent or failed (e.g. cell network error or something wrong). Thanks for future help!
You can use the result parameter messageComposeViewController:didFinishWithResult: to check the status of the message. Its type is MessageComposeResult:
enum MessageComposeResult {
MessageComposeResultCancelled,
MessageComposeResultSent,
MessageComposeResultFailed
};
Bear in mind that MessageComposeResultSent may only be interpreted as a successful queueing of the message for later sending. The actual send will occur when the device is able to send.
How can I check if device is able to send?
To test whether a device is capable of sending text messages, use MFMessageComposeViewController's canSendText class method. According to the documentation, you should always call this method before attempting to present the message compose view controller.
However, this will not tell you if the device is able to send the message now (in case you asked with this statement in mind: The actual send will occur when the device is able to send).
Unfortunately it does not account for cell network interruptions at the very least. For example when in airplane mode the delegate receives a MessageComposeResultSent!
I have filed a radar for this. Duplicating it may get the issue resolved sooner.