How Facebook/gmail chat works when browser window is closed? - facebook

I wanted to know how facebook chat works when any user closes the browser without loggingout.
How does FB know that window is closed and send the message to the inbox and do not attempt to show the ping?

Facebook / GTalk and any other online chat client usually uses a 'ping' or check to see if the user is still online / using the window. You can do this easily by firing off a Ajax call in the background every 1-2 minutes.
Every time the ajax call is made, update the last_seen time in your database. If the date / time exceeds 1-2 minutes (as per your ajax call), you know the user has closed the browser or lost their connection.

Related

Unable to get realtime updates for 1 of my apps

I just finished implementing realtime updates for 1 of the 2 apps I am working on. it worked fine for the first app but the second app doesn't call my server when I make a purchase, I am able to test the call successfully from the realtime updates tab in facebook, I am also able to manually make a post request and have it respond, I just can't get facebook to call the server when I make a purchase.
Any Ideas?
I had this problem with my app, it took Facebook 24 hours to update for some reason. If you're URL doesn't work, test it locally to see if Facebook sends a post request. Create a new app and inside the URI use something like Ngrok or LocalTunnel and check if this works.
Another idea would be to remove all the fields you are listening for, and just add the "feed" option. That worked when debugging another app.

Prevent Deezer connection popup to show automatically

I am developing a deezer web application (javascript SDK).
I have a simple "hello world" player (example from the deezer dev website); if I start playing a song I can listen just to the 30 secs preview and it is correct, I am not connected to deezer.
What I want to avoid is the automatic deezer connection popup window which appears just after the music start playing. What I would like to do is instead explaining to the user why she has the 30 sec limit and invite her to connect her deezer account. That automatic popup is very very confusing for the average user. Is there a way to prevent it?
Furthermore: it is still not clear to me WHEN this popup is showed: if I am logged in facebook (not in deezer, just in facebook), the popup is showed, otherwise is not.
In order to do a test, I have DELETED my deezer account (which I registered through facebook) but it seems that when I am logged into facebook the Deezer SDK still remember me and launches the popup...
Does anyone has more information about?
There is no way to block that popup. It shows up every time a user needs to register/sign up to stream full tracks (usually after getting the 30 seconds previews). Credentials are cached so if the user is logged in Deezer from another browser window or previous navigation (on Deezer.com or any website using Deezer connect), it won't show up and those credentials will be used.
The only way you can be more proactive about the Deezer registration is to guide your user to your own login button (using DZ.login from the SDK) on your page before getting the popup.

Detect when user leave my facebook application

I am developing a Facebook WEB application and I want to know who is currently on line.
How can I detect when a user leave/close my application to change the user flag to offline.
I assume by leave/close your application you mean navigate to a different webpage or close the browser?
The simplest way to achieve this, would be to periodically send a poll back to your webserver using an ajax connection and a javascript timer.
When a user disconnects from your app by closing the browser or changing webpage, the polling would stop happening.
A script running on your server would periodically check the timestamps of the polls of 'online' users, and if it finds one that's no longer up to date, mark the user as offline.
The wikipedia page on Comet (programming) is probably a good place to start
http://en.wikipedia.org/wiki/Comet_(programming)

How to check user is using my application facebook

I want check how to know user is using my application facebook
Example: One user go to application page, i set user online, when user close application page, i set user offline
Thanks.
If you haven't heard from a user for some time, chances are that he closed a page with your app.
Memorize last time a user did anything in your app, and set a timeout. If N minutes later there are no new actions, you mark him offline.

Apple Push Notifications

I'm building an app that checks as site every 15 minutes for changes. I can do this fine in the app, when it's open. But how do I go about doing this while the app is in the background?
The trouble is I don't think I can use the Push Notification Service. The page on the site which is being checked, requires the user to be logged into the site. Because there is a cookie jar for each app, the user logs into the site through a UIWebView at the beginning and then once logged in, the site is polled every 15 minutes using NSURLConnection and receives the data for the logged in user because of the cookies created at login in the webview. I don't believe there is a way to do this on a server for many different users? And if there was wouldn't the user's site username and password have to be stored on my push server which is a huge no.
So can I use task completion, or is it possible to access a page that only appears correct when the correct cookies are present from a server and then use push notification.
Unfortunately there is no way to get the cookie from a UIWebview. And task background completion can only run for 10 minutes.
I'm not sure what kind of website you are trying to access, but if you can replicate the login using a NSURLConnection you can retrieve the cookie using NSHTTPCookie. Then store the cookie data on your server and then access the web site from the server with the "Set-Cookie" header to check the content for changes.
This, of course, depends on how long the cookie lasts (expires).