Xcode chat app, creating dynamic views - a little lost - ios

Am just about to start doing an iphone application which is supposed to have a multi user private chat. Something like facebook style, where the user has a list of friends and he can chat with them independently. I just need a little direction here
If i have a list of users, let's say i create individual views for the chat, how can I handle these views? If jim is chatting with dick and jane, there should be 2 views, each for one chat window right? Are there any references that i can use.
I am looking for references in socket programming where i can push messages to the user from the server. I have been looking but could not find anything helpful.
If i try to update the user's chat window using local notifications, lets say request data every couple of seconds, will that be battery draining?
I would really like some direction here, i do not want to start something just realize its the wrong way.
Any help is highly appreciated

Those all sound like design decisions. For example, do you want to display each user's messages in a separate view? That's entirely up to you.
You'll want to read about iOS Push Notifications.
If you mean that you intend to poll some server for updates, then yes, that will use a lot of battery. This is exactly the sort of situation that the push notification system was created to help you avoid.

Related

How to invite users to join a multi player Gaming Session using Parse (swift)

I'm trying to develop a trivia app, much like Quiz Up but with multi players.
Here's what I thought of doing:-
Creating a class called 'Game Session' on Parse, that has information of who created it (PFUser.current), the name of the gaming session(name), and the names of users invited(invited_users). Think of this Gaming Session as a closed group where the users interact with each other only.
So there's a createSessionViewController, and a joinSessionViewController.
If User A creates a gaming session (in createSessionViewController) and sends invites out to User B and User C, they get to accept or decline these invites in joinSessionViewController.
Now from what I have researched is that I would have to query through all the objects in the class Game Session (in viewdidload of the joinSessionViewController) and use query.wherekey for eg, User B's object id is in the column "invited_users". If so, I return that Gaming Session's object. Is that right?
If that is the case, is that an efficient way of doing it? Because it seems like if the app gets popular and there are lots of objects in the class, then it could take up a lot of time to get the one object with User B's id.
I hope I made myself clear and you guys understand my question.
PS: I'm sort of new to parse and swift, so if you could give me detailed answers it would be much appreciated.
Your logic is correct but I would also strongly suggest you take a look at Parse-LiveQuery. This tool allows you to subscribe to a PFQuery you are interested in. Once subscribed, the server will notify clients whenever a PFObject that matches the PFQuery is created or updated, in real-time.
https://github.com/ParsePlatform/parse-server/wiki/Parse-LiveQuery
https://github.com/ParsePlatform/ParseLiveQuery-iOS-OSX
Your assumption is correct and that is indeed one way you could go about doing that although it has drawbacks as you mentioned. If you felt like putting more effort into it, you can write JavaScript parse cloud code that executes after an item is saved (for example after a game session is created) and send out silent push notifications with the new objects id to the users who were invited. You could then use that push notification data to know the exact ids instead of having to query for them. This is much more advanced though. For whatever your app is, the simple route of having a model query the data on load should be fine. If you find yourself in a situation where performance is hindered due to this, well then congratulations.

Is twilio a good choice for implementing this scenario

So basicaly, we already have a website that allows users to be in the same room to visualize schemas, interact with it, chat about it, all under the control of an admin of the room that monitors what other users see.
We are looking to add an audio conferencing feature, and I'm currently doing a technological watch on which Real Time Communication solution would be the best to fill our needs.
Our problematic is simple.
The admin would have a button "start a conference" to create a room.
When the room's created the other users would see a message like "The admin launched an audio conference, would you like to join."
If user say yes, they would be able to hear and talk to each other.
Our only constraint is to never leave our website.
Could this be done with Twilio ?
I'm not at all part of Twilio, but I'm doing something similar in a project and I would say yes, Twilio is a good choice. Although, Twilio is the only company that I've tried, because my client asked specifically to use it.
See here: https://www.twilio.com/webrtc
Just have in mind, that maybe Twilio is not the cheapest option.

Share objects between people who are using the same app in real-time (push)

I'm pretty new to objective-c, so i came up with this..I've found other similar questions, like mine, but there were all different at some point..
So, i have a tableview which contains cells, and the cells are containing data (NSManagedObjectModels). I have this app on 1 device, and I'd like to share these cells, i mean data, with other people, who are using the exact same app (i'd like to use only wifi or network connection).
Just like in Reminders (in iOS pre-installed app) when i create a new list, i have the option to share it with someone else(s), and the person who i've shared with, can see the list i created-immediately.
Is there a simple, or any way to accomplish that?
The simplest way would be to send a push notification to all users with a URL linking to data you want to share.
But even that means that you'll have to have a server store away details of push tokens (so you can push to each device) and then provide some way for users to group different devices...
I would look the sessions on CloudKit and see if from that you can see a way to do what you want, otherwise look at libraries that provide easy server integration to make passing data up to the server easier.

is it possible to send a directed flash message in rails?

this is kind of a dumb question, but is it possible to send a
flash[:success]
directed to a certain user other than the current user on the screen? in one of my controllers i have
if #article.up_votes.count > 10
flash[:success ] = 'something'
end
is it possible to send that flash to the owner of the article? as opposed to my own screen? or is there another way to do this?
i tried looking through
http://api.rubyonrails.org/classes/ActionDispatch/Flash/FlashHash.html#method-i-notice
but couldn't find any method that would help. maybe i am reading it wrong? is there a way to achieve the same effect then?
thank you...
Not using flash, you'd have to try something else, there are lots of ways to go about it, but flash isn't one of them. Well, you could still use flash, but it wouldn't be to send from one user to another, you could cause a flash message to appear for the user being notified.
First thing to figure out is how do you notify the other user, when would he get that notification, do you want him to get notified anytime he using your site? Or only if he does something specific on your site?
For what I know the best way to go, maybe the only way actually is push notifications. There are many ways to achieve this but I think faye should be the easiest.
See this screencast to understand it and later. You want to have a channel for each user so it will be the one to get that message. Further search for private pub so nobody's can listen to others channel
http://railscasts.com/episodes/260-messaging-with-faye
http://railscasts.com/episodes/316-private-pub
As ismaelga mentioned I also think push notifications is the way to go (WebSockets).
In addition to Faye you can use a hosted solution called Pusher (pusher.com).
Here is a really short description about how Pusher can help you. Bassically all users using your application listens for messages on a WebSocket-server (through JavaScript). In this case Pusher. You can then send messages to Pusher via your Rails application. When you send a message to Pusher, all users will instantly be notified about the new message via JavaScript (through the WebSocket). To only notify a specific user you can use Pusher's "private channels"-feature.
Pusher have some really good documentation on how to use their service: http://pusher.com/docs/javascript_quick_start
This picture (taken from Nettuts+) might also give you a better understanding of how Pusher works: http://d2o0t5hpnwv4c1.cloudfront.net/1059_pusher/pusher_websocket.png
Hope this helps a bit.

Integrating twitter,facebook and other services in one single site

I need to develop an application which should help me in getting all the status,messages from different servers like Twitter,facebook etc in my application and also when i post a message it should gets updated in all the services. I am using authlogic for authentication. Can anyone suggest me what gems/plug-ins i can use..
I need API help to get all the tweets/messages to be displayed in my application and also ways to post the messages to the corresponding services by posting it from my application. Can anyone help me from design point.
Walk through what you'd want to do in your head. Imagine the working site, imagine your webapp working before you start. So your user logs in (handled by authlogic) and sees a textbox called "What are you doing right now?". The user fills in a status message and clicks "post". The status message appears at the top of their previously posted messages.
Start with the easy part. Create a class that posts to two services. Use the twitter gem and rfacebook to post to two already defined services. In the future, you'll want to let the user associate services to their account and you would iterate through the associated services and post the message to each. Once you have this working, you can refactor or polish the UI a bit to round out this feature. I personally would do the "add a social media account to my profile" feature towards the end.
Harder is the reading of the data (strangely enough) because you're going to have to figure out how to store it. You could store nothing but I suspect you'd run into API limits just searching all the time (could design around this). I would keep a little cache of posts associated to the user's social media account. In this way, the data model would look like this:
A user has many social media accounts.
A social media account has many posts. (cache)
Of course, now you need to schedule the caching of the posts. This could be done manually, based on an event (like when they login) or time based. So when the update happens, you load up the posts for that social media account and the user will see the posts the next time they hit the page. For real-time push to the client's browser while they stare at the screen, use faye (non-trivial) and ajax to pull the new posts to the top of the social media stream view.
The time based one is tricky because you'd either have to have a cron job run or have rails handle it all with a gem like clockwork. But then you have to leave rails running. I've also solved this by having a class in /lib do all the work and a simple web call kicks off the update. But it wasn't in a multi-user use case. So that might not work. In any case, you'll want to have some nice reusable code for these problems since update requests can come from many different sources.
You'll also have to deal with the API limits. When pulling down content from twitter, you won't get everything. That will just have to be known by the user or you'll have to indicate a "break in time" somehow.
The UI should be pretty easy (functionally anyway), because you know which source the post/content is coming from. It'd be easy to throw a little icon next to the post to display which social media site it's coming from.
Anyway, good luck, sounds like a fun project.

Resources