how facebook created push notification when its web app is closed - javascript

Recenlty I've notice that I get push notifications from facebook even that I don't have facebook app open. How is that possible?

This is done using the Push API which builds off the ServiceWorker API which allows web applications to register long-lived background services that outlive a specific website visit. As to how this is implemented, even if the browser/website is not in the foreground, there is an application running in the background or there is a handler registered to start/resume the background application when an event is received. Android services enable this under-the-hood.

I think Using push notifications...In mobile computing is that the technology doesn't require specific applications on a mobile device to be open in order for a message to be received. This allows a smartphone to receive and display social media or text message alerts even when the device's screen is locked and the social media application that is pushing the notification is closed.

Related

Progressive web apps and Web socket connections in background

What should be the expected behavior when I add my webpage to home on Android device and my page contains a websocket connection. Should it still gets updates even in the bakground?
Based on my quick demo, it stops receiving updates when in the background. Also i dont have a service worker hooked up yet, its just opens up in full screen as a pwa.
Service Workers live for a limited amount of time (on the order of 5 minutes). They can not maintain persistent connections like WebSockets.

How to keep the app in the background after closing - PhoneGap

I would keep my PhoneGap application in background after closing it in order to generate notifications.
I wish my application available on iOS , Android and Windows Phone with notifications.
Is it possible to execute the JavaScript when the application is in the background ?
How to do ?
On iOS there are two kinds of notifications - remote notifications and local notifications. Remote notifications are delivered by your webservice through APNS and require for the device to be connected to the internet.
Local notifications on the other hand are scheduled on device. The most important thing is that both will wake your app for a short time, so it can consume the notification and decide what to do with it. During this time you can of course schedule another local notification.
This - https://github.com/katzer/cordova-plugin-local-notifications - seems like a good place to start investigating.

update native google maps app from a web app

Can I have a web app running, and a native google maps app launched by the web app running on a droid, and have actions performed by the user on the web app automatically update the native map app?
Ex. User clicks link on web app. Query string values in the address feed maker points to the maps app and it launches in the native app rather than a browser if the user chooses that. Then, user goes back to web app, makes changes. When user goes to map app, changes on web app are already reflected in map app via some sort of push notification system from the web app to the native map app.
Is this at all possible to do?
if you are talking about web app runs on the same devices, you can at least use some URL scheme to open the native Maps app. But there seems to have no way for returning the information back to your web app. (well, for the sign-in app, there seems to be some connection and data sharing between the signed in devices, but not sure how it works.)
but the ultimate solution I can think of to this question is to develop your own version of the Maps app, which should be an app that use Google Maps API to do basically the same thing the google maps does, which also sync data with your backend web server.

Cross-window/tab in-browser notifications with JavaScript

I am working with a website having a chat functionality (think Facebook chat).
I'd like to play a notification tone when a new message arrives. However, the user may have multiple tabs opened and the message arrives to the multiple tabs, as the chat session is multiplexed across different browser tabs/windows.
How to determine
If a browser has many tabs (windows) open for the same website
When a new message arrives which of the tab(s) should play a sound effect
I am aware of the Notifications API, but I'd like to solve this problem in backwards-compatible manner. Also if there are any related JavaScript libraries I would like to know about them.
You can use localStorage for such purposes. Data in localStorage is shared between all windows (tabs or iframes) with the same origin. It also can notify your application about changes in localStorage.
See IWC library. I think it will help with your tasks.

Firebase simple login using appMobi pop-up windows

I am trying to use OAuth simple login from Firebase on mobile devices using Intel appMobi.
<button onclick="authClient.login('twitter');">
<button onclick="authClient.login('facebook');">
<button onclick="authClient.login('github');">
<button onclick="authClient.login('persona');">
When working on a web site the Firebase simple login works fine for Facebook, Twitter and etc. The user gets a pop-up window to allow login.
When using the appMobi emulator the pop-up window will show up outside the device being emulated and nothing shows up when when the software is loaded onto a mobile device.
Is there a way to get this to work on mobile devices using Javascript?
Firebase Simple Login currently requires fully-fledged pop-ups to be enabled in the browser environment, which is why you're not able to use it in appMobi. While I'm not fully familiar with appMobi, I suspect that it does not allow opening arbitrary windows via window.open and then permitting cross-frame communication via postmessage to the opener.
Redirect-based flows are on the roadmap for Firebase Simple Login which would be a suitable workaround provided there were a way to redirect the user from a foreign page back to your application, but I don't have a timeline on that feature. As an alternative, check out the third-party service Singly, which offers a native integration with Firebase.

Categories