Is it possible to push browser notifications from a rails app - ruby

I'm wondering if there's some way to push browser notifications from a Rails app using a gem of some kind I've been doing a lot of googling about this and can't seem to find anything. Any help would be greatly appreciated!

DuckDuckGo-ing not happening here either.
The current answer is there doesn't seem to be a simple answer. There's often a client-side (js) subscription UX and a backend of some sort which can send pushes to the browser (because the browser does the polling for notifications to various PN providers user has subscribed to, which may vary by browser PN api) even when the user is not visiting the website. To see it in action, browse from a modern Chrome to CNN*, subscribe, close the CNN tab but leave the browser open to see a PN when a news story lands. You may opt for Pusher, ZeroPush (acquired by Twitter and folding into Fabric) or Roost (none of Roost's demos work on OS X on any popular browser with zero extensions and a crazy fast internet connection) if there's coin to drop to get going sooner.
Note for Chrome: There appears to be at least two (2) PN APIs, the older Chrome Extension Push which is being deprecated and Chrome Web Push, which can forward PNs to the OS which works off-page. Not sure if CEP works without being on a PN-enabled page... or the current state of PN in other browsers like FF (webpush), Safari, IE/Edge or mobile browsers.
This also seems like fertile ground for someone awesome to contribute an errbit-like Rails app/gem. By looking at push-api and/or sniffing your traffic, it might be possible to reenigne a somewhat simple and robust lightweight server for self-hosting (say using Sinatra, Node or Go) that works for most major browsers.
*Yes, same the news org which closed its investigative journalism unit to focus on "hotel" and "talking-head" "journalism". See VICE (where Kaj Larsen works now), Channel4 and Journeyman Pictures for alternatives.
Btw, for related mobile app (not mobile browser) PNs: have look at ruby-push-notifications... most ecosystems require installing an official app in order to use their PN systems.
Chrome + OS X PN

Rails is server side. To be able to do this you need something in the javascript you're sending back to the client to do the job for you.
the way I would do this is have something on the client, in javascript, that goes back to the server - in an async manner - and checks to see if there are any notifications to display.

Related

How do browsers(Firefox more specifically) know which cookies are tracking cookies

I came accross to a situation where Firefox in incognito mode blocks some of the cookies on my site. More specifically google analytics cookies like _ga, _gid, ..etc. Searching in the internet I came across to this article. So browsers like Firefox somehow identify these cookies as tracking. But how? How does it know which cookies are tracking and which not? I need to know this because next time I set cookies on my server I dont want them to be blocked by browsers.
In context of the article it just means blocking reference links. For instance it blocks sending the referral information from, for instance Facebook, to other sites.
Other sites use the referral information to decide who to pay to get more traffic and stuff like that.
There's like 100 different versions of the idea of "tracking" though.
Like the article points out, your ISP always know every DNS search you do and every call to an IP so they always know ALLLL your traffic and are "tracking" it.
There's also "ad tracking" where all those google calls send out what the crawler says is on the page in order to create targeted ads and all that.
I think, based on what you wrote, you're just talking about tracking links which is just scrubbing the referral link part though.
You'd have to be more specific if that's not what you're looking at.

(Eddystone) Is it possible to get the number of times an URL is received by a device without writing your own app?

Is it possible to get the amount of times an URL is received by a device from the proximity beacon API? I want to know what the click through ratio is of the broadcasted URL.
That depends. If you write your own app that scans for Eddystone-URL beacons and triggers some content (e.g., the web page itself) off of that, then naturally you're in full control and can implement this kind of analytics. Though it'll only apply to people which installed the app.
If you rely on Chrome for iOS, or the Physical Web iOS and Android apps to discover the Eddystone-URL beacons, then these apps do not provide any such numbers.
However, both Chrome for iOS and the Physical Web apps do fetch some metadata about the URL they detect, such as the page title and page description, without the user first clicking on the link. So there's a slim possibility that you could filter such requests out (they will be made by the Physical Web Service, or some similar "bot"), separate them from the actual visits, and do analytics based on that. Most likely however, this "bot," or the proxying service (which is there precisely to prevent this kind of tracking, and protect the user's privacy), will also do some caching, so you'll see fewer requests than the actual number of times the URL is received by the device.
And finally, dropping to a lower level, a note: most beacons are uni-directional, i.e., they broadcast information, but don't receive any information back, so beacons themselves usually can't count the number of packets on the receiving end. (I guess you could technically use the Bluetooth "scan response" mechanism to do that, but it would require custom beacon hardware/firmware.)
Unfortunately, no, it will not do this by itself.
Google's Proximity Beacon Api is a server-side system that stores metadata about beacons (location, battery level, etc) It requires you to add special client code integrated with your app to submit detection data.
Similarly, detecting Eddystone-URL beacons generally requires you to add custom code to your app to do the detections and and present the URL to the user. (The only exception to this is for some Chrome for iOS users with the Chrome Today widget enabled, and no public system provides click through rates.)
Since your app must present the URL itself you really have to roll your own solution to this problem.
If I understand right, you should be able to achieve this by Google analytics campaign. Setup a campaign, add campaign url to ibeacon url and you should be able to check the details analytics through Google analytics.

Facebook style auto loading

We are developing a free, open source Google Reader alternative at http://reader.pykih.com and the code is at http://github.com/pykih/reader
When a user signs up or adds a RSS feed, we add the feed url to the database and then ask a DelayedJob to fetch articles from that RSS url. This typically takes few seconds to minute or two, depending on the DelayedJob queue. Many users have complained that RSS feed is not being fetched at all when in reality it is being fetched. All that the user has to do is refresh his own page. We wrote a message there, yet users are complaining.
Can anyone point us in direction towards - what is the best way to design a Facebook or Google style "Loading" (icon in yellow) functionality and once loaded it automatically adds the entries to the screen without page refresh.
Thank you in advance
If I understand correctly, you basically want to update the user's view of the page while it's still open, in real time. (At any rate, that's what Facebook and most Google products do nowadays). This technique is usually called server push - information is pushed from the server to the client, instead of having the client request (pull) information from the server.
There are multiple ways to implement server push.
You could use AJAX to 'reload' the page every ten seconds or so. This is very easy to implement, but not realtime at all, and could cause unneeded load on your server. It works with all browsers.
You could use EventSource, a relatively new format supported by Firefox, Chrome, Safari, Opera and others (but not IE). It's a very simple format and easy to implement. EventSource is one-way communication only: it sends events from the server to the client, not in reverse.
You could use WebSockets, probably using a library like EventMachine and a WebSocket library. WebSockets allow fast bidirectional communication, but it's more complex than EventSource and only the newest IE versions support it.
You could use a commercial service like Pusher. Pusher is easy to integrate and fast, but not free. Browser compatibility is great, though.
The options differ primarily in the amount of client support (do you need IE support?) and the amount of Ruby integration you get.

Fast, non-ajax (I guess) updating information

I'm looking forward to know how they do this. They update their information on just a couple of ms and I see no AJAX requests on my firebug console.
Here is the page: Económico
As you can see on this two images below, this is the information they are updating.
Thanks for your help, looking forward to extend my knowledge!
They are making requests using websockets
e.g.
Request URL:ws://ortc-prd2-useast1-s0002.realtime.co/broadcast/444/m38tirp9/websocket
Request Method:GET
The responses are in Frames
So not your usual stuff, what firebug are you using? It is likely not reported in the console, but in the Network tab.
That's done using WebSocket.
Look at the network tab in chrome dev tools and you'll see it.
They are using Realtime.co, which I work for. It's a full-blown real-time communication platform that handle all the nasty stuff for you: scalability, security and automatic fallbacks when a browser does not support websocket.
You can get your own free account at Realtime.co and give it a go. You'll start doing your own cool real-time enabled applications in not time.

Session state persistence between web page content and XmlHttpRequest for Mac dashboard widgets and Safari extensions

I already posted to Apple's Safari dev forum but got no responses so thought try cross posting elsewhere to get ideas:
I'm asking this question in regards to both
Safari Extension (toolbar type AJAX extension)
Mac OS X dashboard widget
I assume both will be similar as they use the WebKit rendering engine?
I would like to know if the engine for maintaining built in session state support (cookies?) shares and persists the session between web content loaded on the page by the browser engine (HTML, JS, CSS, images, etc.) and requests made by XmlHttpRequest object.
I'm porting an AJAX app that requires session state that's shared between web content and XmlHttpRequest object. (i.e. no explicit cookie management for session state, at least not defined by the web service API that I use).
I successfully ported the app to Chrome, Opera, Windows 7/Vista gadget. It failed to work on iGoogle, and Mac OS X widget. Safari extension port had mixed results - it works in some cases but not in others.
I also did a Microsoft .HTA port (HTA app = web app to be run via IE w/o security restrictions of normal web apps, like cross domain XmlHttpRequests) and noticed that works only with IE7+ (due to implementation differences of native XmlHttpRequest in IE7+ vs MS XML version of earlier IEs)
I had consulted discussion/support group for iGoogle as well and learned that iGoogle too doesn't support such session state support.
I kind of worked around iGoogle issue by using Flash component to perform XmlHttpRequests which seemed to be able to share the overall browser session and thus work. I'm attempting that for Mac widget, it didn't seem to work. Can Safari toolbar extensions make use of Flash?
In any case posting this thread for more insight like if Safari/Mac is like iGoogle and not support a shared session between web content and XmlHttpRequest (or no cookies even supported).
FYI, the app I'm working on is below, you can try out what I have to investigate issue. When session state support fails, you get error message that need to enter code correctly (that's what the web service returns in this case, not very helpful to the user).
http://code.google.com/p/autosmsclients/
I've already hosted code for Mac OS X widget and Safari extension there.

Resources