Checking online status from an iPhone web app - javascript

Is there a way to check to see if an iPhone is online from a web app. That is, in mobile Safari, can I check the online status of the device to see if I should try an AJAX call or not.
In Firefox/regular WebKit, this would be:
if(navigator.onLine)
{
onlineCode()
}

img src="http://aonlinesite.com/a-really-little-image.png" onload="Intenet!" onerror="NoInternet!"

A quick test on the iPhone shows that it is available from iPhone OS 2.2.

That same code should work in the WebKit nightly build as of May 16th 2008. I guess that means you need to hope the 2.1 update included a new build of safari.
https://bugs.webkit.org/show_bug.cgi?id=19105

Related

Simulate a IOS environment for test website in safari

I'm developing an simples website using html, css/bootstrap and JS. I received feedback by Iphone user that some features not working in IOS mobile. Some Images not loading and counter-up not working too. In windows and android is working fine (chrome and Firefox). The question is, how I create a environment for simulate a IOS mobile for check how safari browser load my site? I tried install safari in windows but it not show equals execution in IOS. I think that browsershots not is a good ideia, because it works only with static content, and in the moment return 500 internal server error.
Microsoft BrowserStack provides a full test environment, however beyond the complimentary trial period it is not free. For errors related to pageload or reference, I would suggest you use device emulation and network throttling in a browser: Safari, Firefox, Chrome.
Some browsers are more forgiving of errors, so you may even have a typo. Is your trustworthy friend using an outdated browser while you require modern feature support? The scope of the problem seems undeserving of a bill for membership or tech support.

Webcodecamjs-QR code scanning Library not working in Safari browser

I want a mobile page to scan QR-codes and display it's content.
This is the page:
https://ndvibes.com/demo/TicketSystem/check (index.html)
Very weird, it's working on Firefox (Linux), but not in Safari (iOS 11.4 /iPhone 6).
I thought the library I used didn't supported Safari, or Safari restricted
it because of security reasons, but the demo of the library is working just fine on iPhone!
So it Safari seems to be supported, and it doesn't block it, because it's working in the demo...
I have no clue on how to fix this.
Safari asks for permission to access the camera, when granted, it just does not display the camera-content.
I also checked the settings of Safari, but didn't saw anything disabled that could block the webcam-video to show.
Edit: This code doesn't seem to work on Android either, very weird, the demo is working on desktop and mobile, and my own code is working on desktop, but doesn't work on mobile...
To Use on Apple devices you have to make sure:
1- You must use https, for the protocol http does not work.
2- You must use Safari because in Apple, the other browsers do not have permission or access to some javascript things.
3- must use some version so you can use both cameras.
Problem: I thought the library I used didn't supported Safari, or Safari restricted it because of security reasons, but the demo of the library is working just fine on iPhone!
Reason: I have gone through with your webcodecamjs.js and compared with demo webcodecamjs.js.I found that there are some differences in these files.May be lib-code taken from git and actual demo lib-code are diffrent.
Solution: Simply replace your webcodecamjs.js with demo webcodecamjs.js and it should work.
EDIT
Note: You have to start the camera by event trigger as Safari doesn't allow Autoplay.

Chrome for Android: Vibrate API

When trying to use the Vibrate API in Chrome for Android (tested stable version 43 and dev version 45), it never vibrates. Using the simplest code:
window.navigator.vibrate(200);
When ran from the Javascript console, it returns true. Vendor prefixes don't fix it. The Chrome Status website shows the API was implemented in version 32. This code works in Firefox for Android. Is this a problem with Chrome or a problem with my code?
Stupid me, Chrome For Android follows what sound profile you are currently on. While Firefox does not. So to feel vibrations your sound profile must be on vibrate or above.

How to connect to iPhone's webkit debugger?

new iOS 6 feature is, that you can debug html and javascript running on device or simulator in desktop safari. I suppose, that this feature is based on Webkit Remote Debugging Protocol.
How can I connect to webkit running on iPhone without desktop Safari?
I can do this for mobile Chrome running on Android using websockets, but how can I do that for iOS devices?
The ios-webkit-debug-proxy project (from Google!) does this.
You want to look at this code https://github.com/leftlogic/remote-debug/tree/master/safari - although it fails when it actually comes to RPC calls that use __rpc_forwardSocketData.
If you've got any ideas why several of us are interested!
You need to open up the iPhone Simulator and browse to a website.
Then open Safari and choose "Develop" from the menubar. There is a the option called "iPhone Simulator".
If you hover over this you can see all of the open websites of the simulator.
This gives you the same inspector Safari uses. You can even see hovered elements in the iPhone Simulator.

SignalR on mobile web?

I'm evaluating SignalR technology for use in our new product (mobile web application for the broad audience, among other things it needs a real-time chat on some pages).
I've followed the guide to create a very basic chat demo.
Then I deployed the demo on my IIS, and started chatting to myself.
All clients were on the same WiFi network.
Desktop browsers worked more or less OK.
However, Safari on iOS 4.2, and IE on WP7.10 - they both sucked.
Sometimes nothing happened when I pressed the "post" button.
Sometimes outgoing messages were sent OK to the desktop firefox, however there was no incoming messages.
Maybe I'm missing something obvious? Maybe I need jquery mobile instead of the normal one? Maybe I should just tune the IIS/web.config/whatever, and the SignalR will flourish and start to work flawlessly even through the crappy mobile internet?
Or does it mean that since it doesn't work even while on WiFi within a single hop from the web server, I should throw SignalR away and just write some JavaScript to poll a JSON endpoint for new messages?
Thanks in advance!
I have been developing an app with phonegap (that means that uses the Safari browser) and SignalR for Android and IPhone. The major issue I had was with iOS 6.x because SignalR did not connect with default config. I have found a workaround for that and I had explained it here. Let me know if you find it useful.
This code will simulate a connect, check for messages, disconnect and wait 5 secs to solve the iOS issue.
In js add
$.connection.hub.start({ transport: 'longPolling' }).done(function (myHubConnection) { });
and in Application_Start() add
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
RouteTable.Routes.MapHubs();
Not all mobile browsers (e.g. android, opera mini) support websockets. You'll find a nice chart of supporting browsers at http://www.hanselman.com/blog/YourUsersDontCareIfYouUseWebSockets.aspx

Categories