How to integrate Juggernaut chat server (Powered by ruby on rails) with iPhone/Android app for real time chat? - iphone

Preview:
I am using juggernaut chat server.I am having redis and juggernaut server running on machine. I am able to do chats within my local network on vaious web browsers. Everything is working smoothly. As juggernaut is a server driven chat server so i am quite sure about the scalability thing. Now here is the thing:--
Whats the problem:
I want to have a iphone native app too where user can login and chat with his friends. Now the thing i want to know is how do I push on iphone app, cause for juggernaut client registration a javascript code is needed. Something like this:
var jug = new Juggernaut;
jug.subscribe("channel1", function(data){
alert(data);
});
Basically how do i push new notifications to Iphone chat window. I don't know much about iphone as I am web developer. Still from google search etc I came to know some possible ( may be) ways:-
We can embed a url in iphone window. Is this a good approach?
Other thing we can do is using UrbanAirship kind of services we can do push notifications. Will push notification works for chat? I don't know about that even.
Third option can be polling. Iphone chat client keeps on hitting my rails app for new notifications. But i think this will be a very bad approach.
What are the other possible solutions?
Can any iPhone/Android developer guide me what should i do. I will eventually hire a Iphone developer to do all the coding part. But I want to have a big picture in my mind so that I can provide a complete docs of all the things, and have a clear picture how I want to discuss things with him before writing down the code.
PS: I am looking for a solution which works for android/nokia devices too. Cause later on I will be developing an application for that too. Basically it will be good to have a same solution. if not then compatibility factor should be there atleast.

Apparently there is WebSocket support in MobileSafari on 4.2 (source). You could probably write up a client that uses an embedded UIWebView to marshall the events to/from the Juggernaut server and deliver them to your app via shouldOpenURL and custom handlers.
You might also look at libPusher by Luke Redpath for interacting with push communication via the Pusher web service.

Check out this library: https://github.com/fpotter/juggernaut-cocoa
It's really easy to use.

Related

Messaging service within my app

I need to implement a message service into my app that works exactly like this:
users register with a nickname within the app
they can add contacts (just nicknames) and send them a message by just specifying their nickname
they can send a message whenever they want, and the message is stored on a server until when the receiver connects to internet.
when a message is received, a push notification is triggered.
So, the messages work pretty much like emails, however instead of using email addresses, we only use usernames. I'm also going to build my own back-end for it.
Which APIs should I use or which 3rd party framework can I use ?
And any tip ?
N.B. I need to make it work with iOS 3.0 as well.
and in the future I will develop an Android app, so the nicknames should be unique and I should be able to send messages from iPhone to Android devices within the same app.
thanks
I've successfully used the Three20 library and would recommend giving it a try. It's an open source spin-off originated by the author of the Facebook app. It features a bunch of additional GUI components that might be useful to your project, like a message composer that resembles the one used by Apple's email app.
Also, Three20 features a nice framework for handling navigation within your app. Currently, the biggest drawback seems to be that certain features don't play well with the iPad API.
The answer seems to be Push Notifications

How to make a chat system on iPhone?

I'm doing research for making a chat based app for the iPhone (it's not really text chat in the regular sense, but the principles are the same).
Maximum 6 people can be logged into the same chat room at any one time, and the most basic question is how to efficiently check for new messages?
Would I need to simply poll the server periodically? Or is there a way I could trigger an event on the phone from the server whenever there is some new content to pay attention to?
If having to poll all the time, I worry about the resulting lag as each participant will have to wait longer for others before they can post their own responses to others. And, potentially it might also be too much to handle for the server to respond to lots of requests all the time. It would also waste bandwidth, which is not free for the user...
Unfortunately I will not be able to set up a socket server for this app, it has to be based around a regular LAMP configuration.
I think you can either go with push notifications, or XMPP (Jabber) server.
XMPP will allow your iphone app to receive data even when in the background using the new multitasking features (listening for a socket), and i'm pretty sure you should find ready to use servers for LAMP (or at least open source implementations).
Note that the iOS4 multitasking API doesn't support polling in the background, so your only other option should be push notifications. If you're new to push notifications, you can maybe use a service like Urban Airship that might make the process easier.
XMPP sounds good for you idea, i think this is the best technology for Chat. It alos works great in iOS apps.
Maybe this code sample will be helpful to start using XMPP in iOS app - look at this QuickBlox Chat code sample. It demonstrates how to integrate 1-1 Chat, Chat in room into your android application. Also there is guide how it works. I think there will be no problem to integrate it into your application. Otherwise - Comments system below allows to ask any question you want and get fast answer.
Also there is Demo video http://www.youtube.com/watch?feature=player_embedded&v=SncQaJBBW_0 how this Chat works.
In my opinion the best solution is socket, but you say that you can't implement the server side for this.
You could also implement it with push notifications. You can receive the push also when your app is running and send all the data you need inside the push. Usually chat messages are short...
If you don't want to mess with push notifications on the server then the only thing left, as long as I know, is the polling.

How to asynchronously receive data into a Rails app from an iPhone app?

A large part of a project I'm working on now deals with sending certain messages, which can easily and preferably be XML, from an iPhone app to a Ruby On Rails app. The webapp will have to instantly show these messages, so reloading the page isn't really an option.
I've been unable to find any info re: creating this sort of listening process for a POST request, can anyone guide me in the right path, and perhaps shed some light on what I should be doing, if I am overlooking something?
edit: Would using sockets be smarter? The apps will be run from iPod Touches/iPads in the same wifi network.
Thanks!
What you're trying to accomplish is doable, but certainly not one of the strengths of Ruby on Rails. If you need to update messages in the browser in realtime you can use JSSockets. But you need a server backend that is able to deal with lots of persistent connections like nodejs or if you prefer to use ruby EventMachine. If you still want to receive the messages via your rails app, the flow of data would be
Rails app receives the Message (say by POSTing XML to /messages)
The rails app posts the message into a message queue. Have look at resque
The Evented server listens to the queue and posts messages to the browser
Update:
Sorry, I misread your question as the iPhone app being only the sending part. Unfortunately you can't use JSSockets on the iPhone as it comes with an Adobe Flash component for communication. However, you still have the option of using long polling or implementing the socket in Objective-C and pushing the received objects into your webview via [webview stringByEvaluatingJavascriptString].

What is good way to register users from phone app

We have a web application and we've built phone applications (iPhone, Android, BlackBerry) to be companions to the site. The usual workflow is that an existing user of the site gets a phone app and then plugs their existing credentials into the phone app and they are off and running, but more often now we are seeing folks who are downloading the app and then (and this should not surprise anyone) don't read the help screen that explains they need to go and get credentials at the web site and therefore cannot connect to the application which does require registration to manage their content. This is a giant usability fail condition.
So we know that we need to put user registration workflows on the phone app.
Other than the obvious solution of duplicating our registration page on the mobile, does anyone know of a better identity solution for the phone? For example, on the desktop we also use Facebook Connect as an identity server and the users love it. I'm looking for something that simple that we can implement across the major smartphone platforms.
Clarifying note:
I should add here that this registration mechanism is likely to; and it would be desirable if it did, go hand in hand with a general identity/authorization mechanism such as the Facebook mechanism mentioned below.
One other place I'm poking around is to see whether there's an openId solution that does not require a browser to pop up.
Restful service might be the e asiest way for you to achieve this, you can use it on any device that can make http requests, so you can make your own login screens and talk to the s ervice that way...
Facebook has a Connect API for the iPhone. Integrating it into your iPhone app is very smooth.
http://developers.facebook.com/connect_iphone.php
On the BlackBerry we were able to build a fairly robust REST pipeline between the client apps in the field and our servers. We primary use the framework for updates, but the device API is generic enough to be able to build almost anything you need via standard HTTP/HTTPS GET/POST calls.
On the RIM platform, look into the HttpConnection API as a starting point. There is also an example on the BlackBerry Developer's site which will help. Finally, I believe there are several examples inside the sample package that comes with every BlackBerry JDE (IDE + API download).

iPhone: Need suggestion for SYNC contact

i want to create a application which sync my iPhone contacts to my server and vice-versa.
i read a article on google Get Google Sync on your phone . i want to this type of feature which directly update the contact without user interaction (however one time setting is desired).
any body have idea how the google sync work .
Please advice me that how can i achieve this task. any suggestion and link is greatly appreciated
I think it's important to separate the two overlapping approaches in your question.
Firstly, Google Sync is essentially a way to use Microsoft Exchange protocols and to setup a Mail / Contact / Calendar profile on an iPhone. The iPhone OS supports this feature, not an iPhone App in the App Store. Google Sync leverages this fundamental capability of the phone by exposing the data (mail, contacts, calendars) via these known protocols. If you want to expose data in this way to your users, setup a Microsoft Exchange server and ask questions on serverfault.
Secondly, there are iPhone apps. iPhone apps sold in the app store are not currently allowed to run in the background. This means you can't emulate functionality like iTunes or Mail where your music plays while you are browsing the web, or mail checking is done while you are playing a game of Mini Squadron. If you want this backgrounding capability, file a bug/enhancement with Apple.. However, you can interact with iPhone contacts (Address Book) via the API.. You can also of course "re-invent the wheel" and expose the data however you like via the internet, and consume that data from a custom iPhone App with the one caveat that users would need to actively launch your application to get to this data and it would not be integrated with the built-in iPhone Calendar, Address Book or Mail applications. Some good examples of that are some of the music community apps that have messaging systems built into them. Presumably that is all being done with web services.
EDIT: It is also worth mentioning that should you go the "iPhone App" route, you should at least consider if push notifications are right for you, and if so how you will handle it.
Have you seen the API-Docs?
http://developer.apple.com/iphone/library/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/100-Introduction/Introduction.html
Next there is an application I use called Funambol - it is a sync4j Server/Client. They have an open source application to sync contacts on the iPhone. Source is somewhere in their repository, informations here: http://forge.ow2.org/scm/?group_id=96
As slf told you your application must run in foreground. This may limit you.
Good luck & best regards,
Florian
The 3.0 SDK will allow your application to read contact data on the phone.
Web services will allow you to publish that data to your server, and receive updates.
You may also want to use coredata to store a hash of all contact data so you can tell what is new / updated and just send that data to your server.