Fake websocket function in Android browser - websocket

I want to run websocket in a browser to connect to a server, or use flash when ws is not available (like what websocket.js does)
but it seems there is a native WebSocket function in an android browser (not chrome), the function has member functions such as close, send etc but it does not work. I can't capture any ws packages on the router when trying to use the native ws to connect to a server.
So,
why the fake ws function exists .........
I'll try to check binaryType of this object, when binaryType is undefined or "" I think it is not a good ws (including ws ver 7-8, servers support only ws ver 13). Is this exact? or anyway better? UserAgent may be a not good idea, because there are lots of custom browsers on android (such as firefox, dolphin, ...), and there is not a good key word to check in UA
when or in which version will the fake ws function of android browser disappear or become real? Although google recommands chrome, but some phones seem running default browser with an icon like the earth instand of chrome.
Thanks a lot!

It seems that Google started work on implementing WebSocket in the Android browser, but only got as far as the API.
The fake API exists across all newer versions of the Android browser, irrespective of vendor. This only changes with Android 4.4, where the Android browser has been replaced with Chrome.
I would not suggest detecting this by user agent or like, but instead detect through the behavior of the fake WS object.
E.g. when opening a trial WebSocket connection, the 'readystate' on the Android browser WebSocket object always remains at '0', whereas with a working implementation it changes.
See also this related question.

Which version of Android are you using?
According to CanIUse.com, the only Android browser that supports Websockets is the 4.4.
Cheers.

Related

Fallback for missing custom tabs with Xamarin and Azure AD B2C

I followed the sample on Xamarin Authorization with Azure AD B2C
That uses Custom Chrome Tabs (and the Safari equivalent).
I do not find any resources on how to handle the case if no Chrome is installed on the mobile device. I just noticed in emulator, it just raises an error dialog that Chrome must be installed. But I do not want to exclude users from signing in/up that use alternative browsers.
Are there any links/tutorials that cover this (crucial) behavior?
MSAL now suports a fallback using the embedded browser of Android / iOS:
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/msal-net-2-released#you-can-now-leverage-the-embedded-web-browser-in-xamarinios-and-xamarinandroid
You can now leverage the embedded web browser in Xamarin.iOS and
Xamarin.Android
In the previous versions of MSAL.NET, Xamarin.Android and Xamarin.iOS
used the System web browser interacting with Chrome tabs. This was
great if you wanted to benefit from SSO, but that was not working on
some Android phones which device manufacturers did not provide Chrome,
or if the end user had disabled Chrome. As an app developer, you can
now leverage an embedded browser. To support this, the UIParent class
now has a constructor taking a Boolean to specify if you want to
choose the embedded browser. It also has a static method,
IsSystemWebviewAvailable(), to help you decide if you want to use it.
For instance, on Android: bool useSystemBrowser =
UIParent.IsSystemWebviewAvailable(); App.UIParent = new
UIParent(Xamarin.Forms.Forms.Context as Activity, !useSystemBrowser);
For more details about this possibility see the article in MSAL's
conceptual documentation: https://aka.ms/msal-net-uses-web-browser.
Also the web view implementation might change in the future
You will have to use a different library such as:
AppAuth for Android
"When a Custom Tabs implementation is provided by a browser on the device (for example by Chrome), Custom Tabs are used for authorization requests. Otherwise, the default browser is used as a fallback."
AppAuth for iOS
"iOS 9+ uses the in-app browser tab pattern (via SFSafariViewController), and falls back to the system browser (mobile Safari) on earlier versions."
(Note that Microsoft Authentication Library is consistent with the IETF's Best Current Practice for OAuth 2.0 for Native Apps that:
"... the best current practice is to perform the OAuth authorization request in an external user agent (typically the browser) rather than an embedded user agent (such as one implemented with web-views)."

Is it possible to push browser notifications from a rails app

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.

Native Mobile Application client side page to page response times

Is there a tool to measure native mobile app (can be iOS or Andriod) client side pape to page response times? I found MIHTool (mobile app) that can help us to get HTTP traffic trace like firebug does for Mobile browser based application but not for native mobile app. Would appreciate your suggestions
I am the creator of MIHTool,if you want to measure native mobile app,all you need to do is use fiddler to set up a proxy from you pc,then set your phone's wifi's proxy to you pc's local ip address.
PS: MIHTool helps more then 50K devs right now,I'd love to post it here so more and more devs can make their job ease and help me to make MIHTool better, but I got banned to post as ADs.

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.

Javascript Error on Facebook Login using Chrome - Unsafe JavaScript attempt to access frame with URL. Domains, protocols and ports must match

I have been running the facebook c# sdk successfully for a good year or more, and it stopped working early december. This was due to the API changes at Facebook, and an informative error told me that i needed to use some new parameters in my calls (specifically oAuth: true )
I read up on the changes, and updated the sdk via nuget, which is now running on version 5.4.1.0 of Facebook.JavascriptMvcWebsite and FacebookWebMvc and the other required libraries that make up the facebook c# sdk.
Now, when clicking the facebook login button i get a different error...
Unsafe JavaScript attempt to access frame with URL https://www.facebook.com/login.php?api_key=251066398241630&skip_api_login=1&display=popup&cancel_url=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%26error_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.%23cb%3Df3570617%26origin%3Dhttp%253A%252F%252Fgem.local%252Ffbb4f09e%26relation%3Dopener%26transport%3Dpostmessage%26frame%3Df1c822218c&fbconnect=1&next=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D251066398241630%26redirect_uri%3Dhttps%253A%252F%252Fs-static.ak.fbcdn.net%252Fconnect%252Fxd_proxy.php%253Fversion%253D3%2523cb%253Df3570617%2526origin%253Dhttp%25253A%25252F%25252Fgem.local%25252Ffbb4f09e%2526relation%253Dopener%2526transport%253Dpostmessage%2526frame%253Df1c822218c%26sdk%3Djoey%26display%3Dpopup%26response_type%3Dtoken%252Csigned_request%26fbconnect%3D1%26from_login%3D1&rcount=1 from frame with URL http://gem.local/Account/LogOn. Domains, protocols and ports must match.
The console window in Chrome then racks up about 5 of these errors a second, all coming from the facebook login dialog.
I have tried modifying the fbChannel.ashx file to explicity use http:// instead of just // (which respects the current protocol) and also have done the same in FacebookInit.cshtml, but none of this is making any difference.
I also modified my facebook app settings to allow deprecated code...
What am i missing here? I understand why the browser is having a fit over cross domain access, but what is causing this? Have facebook completely switched to https? can i still use facebook logins over http?
I have a test site up where you can see the error in action
Any help appreciated.
Clear the App Domain Field (leave it blank) in Facebook Application --> Basic Info

Resources