Whats the best way to handle realtime client-server communication for ios? - ios

Hello there i am working on an education focues application that works like written below:
1- "Teacher" user has a class, with "Student" users listed in main screen
2- Teacher starts an exam
3- Student users will get a notification that the exam has been started.
4- Teacher will observe the students actions in realtime (i.e when u student answers a question, teacher will automatically see which question is answered and if it is correct or wrong)
The application will be an iPad application and serverside will use (sadly) Microsoft WCF.
Here are things that i thought about things that i could do:
Establishing a socket connection with teacher and students via server like a irc chatroom on background
Using push notifications to receive student actions (somehow without showing any "push" notification
(Worst case scenario), teacher's device will periodically send requests about student's exam status
What do you think? What is the best way to do?
Thanks for helping.

Take a look on websocket.
https://github.com/square/SocketRocket
Maybe this lib is your friend, but i can't help you on server side job.

Related

user to user push notifications

I have seen many questions on here and online that address this topic, but they all are from a long time ago, and are possibly outdated. I wanted to get a more recent answer if Firebase has implemented anything recently that is capable of a user to user push notification system, essentially what is used in all chat applications, or if the best option is still currently using Onesignal.
Yes! These days, you can use Cloud Functions for Firebase to do things like send a notification when something interesting happens on the Database side of things.
Here's an example where a user gets notified via notifications when they gain a new follower. Obviously, your part of the database portion will probably change depending on what exactly you want to trigger a notification, but the general theory is the same.

Creating private messages

I'm writing a simple mini-chat with custom User model and authentication via omniauth. The chat uses web-socket faye-rails to send and display messages instantly without refreshing the page. The matter is that I'd like to add private messages - I mean, that I can choose an user and start our own dialog in a secondary chat window. I've looked for the solutions, but everything I found was about e-mailing - with inbox messages, trash cans and so on. So I wonder if there's any solution easy to implement.
The source code of my chat is here
Welcome to push technology and active web design!
When someone logs in, present them with a list of friended accounts and logged in state. For logged in friends, they can select a friend from the list and start a chat session in a new window. For logged out friends, they can send a message that's delivered the next time the recipient logs in.
You'll then have to create a friending mechanism that allows a user to request a connection to a prospective friend, be notified of pending connection requests, approve friend requests, and an unfriend feature. Hopefully that one won't be used too often.
I've worked with Faye & I like Faye but also take a quick look at the beta release of Rails 5. Action Cable will do the same thing and the framework support is better.

How to check address book against my application

In my app, I need to check address book and if ;
a person from address book is installed my app, user will be able to send a friend request,
a person from address book is not installed my app, user will be able to send an sms to relevant person to install the app.
This is actually same as Snapchat. So, what is the proper way to implement it ?
For instance, should I get phone number of the installer and record it to Users table in database ? Then when another user install the app, check all address book against Users table in DB and mark them application installed or not !
Maybe, there is an easy way to do it. So, please help me and provide some sample code for it.
Looks like you can use
CloudKit for the first question part:
discoverAllContactUserInfosWithCompletionHandler
https://developer.apple.com/library/ios/documentation/CloudKit/Reference/CKContainer_class/#//apple_ref/occ/instm/CKContainer/discoverAllContactUserInfosWithCompletionHandler:
You can get users that are also use your app.
For the second part, you can just use Address Book api I think to get all persons in the AB without your app.
https://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Introduction.html
Address Book is deprecated (or will be), so take a look at this WWDC 2015 video Contacts framework: https://developer.apple.com/videos/play/wwdc2015-223/

XMPP Get number of room members without connecting to a room

I have: ios app;
Server: openfire;
Framework: xmppframework from Robby Hanson.
The logic of the app is when user has logged in, the app will push him into a random room which has the fewest number of members.
The app successfully gets a list of all rooms on start from the server.
But I need to know which of these rooms have an empty place for a user!
There is a method called "fetchmemberslist", but it only returns you a list of members of a room when you are connected to that room.
I need something that will do the same without connecting to a room.
Think if I have 1000 rooms. Using this method the app needs to connect to every room, set delegate, activate, wait for IQ, remove delegate, deactivate and at the and go thru an array to find one with the fewest members.
Isn't it too much to do?
I have dig over the whole internet and everything leads to getting a member list when you are connected to a room.
Is there a way of doing this without connecting a room.
Many thanks in advance!
1) fetchMemberList: queries room members, not list of people who are present in room now. Are you really want members, not online users count? Anyway, if you are room admin, this query works without joining room.
2) If you want to query online users, you should use different query - see http://xmpp.org/extensions/xep-0045.html#disco-roomitems
3) Also, no one can forbid you to implement room members/onlines count on the server side and create custom query like <iq id='123' type='get'><freeroom xmlns='my:freeroom:query' /></iq> with response of room JID like <iq id='123' type='result'><freeroom xmlns='my:freeroom:query'><jid>roomname#conference.example.com</jid></freeroom></iq> where roomname was found by server itself.

Configure multiple instances of app wirelessly

I have an app being used in schools, and one of the features is that they can create classes online and enter class codes on each iPad to access a list of students that they can select. What I would like to do is let the teacher configure multiple instances of these apps (i.e. for a "class set" of iPads) from one parent device, or even via the web. It would involve sending a small amount of data, most likely just a class code, to each iPad.
I know what to do once it is sent to the app, the question is how to get it there without making the teacher open the app on every device and manually add the class code. Could this be done via Bluetooth or even Push Notifications? Which option would be better?
EDIT: A bit more information - The class code corresponds to an actual class on the server, so a group of students. The students simply type in a class code and select their name from a list.
I recommend Apple's guidelines for deploying devices in a school via MDM:
iOS Education Deployment Guide
That covers a lot that might give you ideas about how to deploy.

Resources