How to get the IP address of a Samsung Smart TV - samsung-smart-tv

I am creating an application for a Samsung Smart TV. In my app, I need to get the Smart TV's IP address. Does anyone know how to get it?

You need to use the SEF NETWORK to do that, make sure you're include this line in index.html
<object id='pluginObjectNetwork' classid='clsid:SAMSUNG-INFOLINK-NETWORK' style='opacity:0.0; background-color:#000000;width:0px;height:0px;'></object>
Then somewhere in your code you can use function:
var GetIPAddress = function(){
var network = document.getElementById('pluginObjectNetwork');
return network.GetIP(network.GetActiveType());
};
More information can be read at samsung docs: http://samsungdforum.com/Guide/ref00014/sef_plugin_network.html

For Tizen TV, you can get IP address from webapis, i.e.,
webapis.network.getIp()
will return you the IP address of the device.
Include webapi's in your index.html as :
<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>
You can find more details related to Network of Tizen TV on the below mentioned Link:
http://developer.samsung.com/tv/develop/api-references/samsung-product-api-references/network-api

Related

DOMException: Could not start audio source

I'm writing a React App and I'm using Web Speech API for both speaking and voice recognition. I've written some code that works on desktop Chrome.
The way I ask for permission from the user is the following:
navigator.mediaDevices
.getUserMedia({ audio: true })
.then(function (stream) {
console.log('Succeeded');
/*Handle success*/
})
.catch(function (err) {
console.log('Failed: ', err)
/*Handle failure*/
});
However, this same code always goes to the catch callback when used from my Android phone, with the following written to the console:
Failed: DOMException: Could not start audio source
The site asks me if I want to allow microphone usage and when I go into the site settings, it says microphone and sound are both allowed, which makes me believe I've done the user interaction part well.
The site is served over HTTPS (already solved that issue), so I believe this is not an issue as well.
I'm using Xiaomi Mi 9 with Chrome Chrome 86.0.4240.185 in this test.
My first instinct is that I'm doing something wrong here? If this is the case, what?
Otherwise, what can I do to fix this issue?
Check if your Android app has required permissions:
android.permission.RECORD_AUDIO
android.permission.MODIFY_AUDIO_SETTINGS (might be optional)
You can check html or ejs file ;
you have to use in the body tags
Such as:
body
</div>
<script src="script.js"></script>
/body

Google places api error in ionic 2

I am using google places api in ionic app.I places google places api script in index.html. The app allow the user to access wifi within specific place. User get internet access after login with our app. When application launch and user is connecting with our network, user do not have access to the internet. So i get error:
Application Error connection to the server was unsuccessful.
Is there anyway to call the google places api after user has access to the internet to avoid the error?
This has been quickly tested in ionic 1 and it works, no reason it shouldn't in ionic 2. But if you know a proper way to add the script tag in angular, just replace this part. The logic is simply to add your resource on the fly to index.html. Don't forget that connexion can appear while app is already started, and that you don't need to add the tag twice (verifications have to be done). Some edits might be done to adapt to ionic 2, sorry my version was made on the 1.
the function to add the script:
function addScriptTag(){
//STORE HERE VALUE TO VERIFY SCRIPT HAS ALREADY BEEN ADDED
var script = document.createElement('script');
script.src = 'http://maps.google.com...';
script.type = 'text/javascript';
document.head.appendChild(script);
}
in $ionicPlatform.ready (network is not available before that)
//CONNECTED AT APP LOADING
var networkState = navigator.connection.type;
if(networkState !== Connection.NONE){
addScriptTag();
}
//IN CASE CONNEXION ARRIVES LATER
$rootScope.$on('$cordovaNetwork:online', function(event, networkState){
if( /* VERIFY SCRIPT NOT ADDED BEFORE */ ){
addScriptTag();
}
}, false);

using userAgent String How to find request comes from only mobile devices?

In case of Android phone I checked a condition using.
if (userAgent.contains("Mobile"))
but how to check for windows phone or i-phone? not for tablet.
In case of windown phone Will i check many conditions for browser like uc-browser or opera mini.
please confirm me Does userAgent contain common string? using this we recognize request comes from mobile?
You can use the following code to detect Mobile in iOS devices :
if (navigator.userAgent.match(/(iPhone)/))
return true;
And you can detect mobile device for android OS as described by Google in the following link:
https://googlewebmastercentral.blogspot.com.au/2011/03/mo-better-to-also-detect-mobile-user.html
And for Windows Phone use the following condition:
if(navigator.userAgent.match(/Windows Phone/i) ||
navigator.userAgent.match(/iemobile/i) ||
navigator.userAgent.match(/WPDesktop/i)){
return true;
}

How to redirect from Mobile Safari to Native iOS app (like Quora)?

On my iPhone, I just noticed that if I do a Google Search (in Mobile Safari) and select a result on quora.com, the result page launches the native Quora app on my phone.
How is this done? Specifically, is it a detection of the user agent and the use of an iOS URL scheme? Can it tell if the native app is installed and/or redirect to the app store?
I'm reposting an answer to my own related (but was originally Ruby-on-Rails-specific) question from here: Rails: redirect_to 'myapp://' to call iOS app from mobile safari
You can redirect using javascript window.location.
Sample code:
<html><head>
<script type="text/javascript">
var userAgent = window.navigator.userAgent;
if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i)) {
window.location = "myiosapp://"
}
</script>
</head>
<body>
Some html page
</body>
</html>
Just a small improvement of the JS code, if the app is not installed, it will send the user to itunes store ;)
<script type="text/javascript">
// detect if safari mobile
function isMobileSafari() {
return navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/AppleWebKit/)
}
//Launch the element in your app if it's already installed on the phone
function LaunchApp(){
window.open("Myapp://TheElementThatIWantToSend","_self");
};
if (isMobileSafari()){
// To avoid the "protocol not supported" alert, fail must open itunes store to dl the app, add a link to your app on the store
var appstorefail = "https://itunes.apple.com/app/Myapp";
var loadedAt = +new Date;
setTimeout(
function(){
if (+new Date - loadedAt < 2000){
window.location = appstorefail;
}
}
,100);
LaunchApp()
}
</script>
You can do trigger your application to be launched using custom URL scheme, registered by your application with the iOS runtime. Then on your website, write code to detect the incoming User-Agent and if iOS is detected generate your custom URL's instead of regular http ones.

Can iPhone web apps get GPS position?

Is there an easy way to design a website to facilitate an iphone user providing gps coordinates to the site?
I am wondering if there might be a naming convention for form fields for example, to let the user input in an automated way.
I am considering building a location based website and would like to tailor it for iphone (and other mobile users). I realize an iphone app could do this but I'm not equipped to create one.
Here's a snippet on how to read location from the iPhone. Looks like it requires 3.0:
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
function foundLocation(position)
{
var lat = position.coords.latitude;
var long = position.coords.longitude;
alert('Found location: ' + lat + ', ' + long);
}
function noLocation()
{
alert('Could not find location');
}
See: http://mapscripting.com/how-to-use-geolocation-in-mobile-safari
By the way, if you want to use web code on the iPhone, there are a couple middle-ground solutions you could try that don't force you to create a native app but allow you to wrap your site in an app and get access to GPS and other native features.
PhoneGap: http://phonegap.com/
Appcelerator: http://www.appcelerator.com/products/titanium-mobile/
Check out the app SendLocation under navigation by Jouni Erola.
Its a simply app that will send out the lat & lon of the iPhone to YOUR server.
Simply enter your server url to receive the location as HTTP-GET methid
I've don this without any programming. You can:
Download the iPhone app "Basic GPS" from iPhone Store.
Start an account at Twitter.com (if you don't already got one).
Start an e-mail-to-twitter account at Twittermail.com.
In Basic GPS settings use your secret e-mail address from Twittermail.
At Twitter.com/widgets click "Other" to get your HTML-code for publishing your Tweets elsewhere.
Put this HTML code on your homepage.
In Basic GPS you just click the blue "I" (on) button, "Email" and "Send" to send your position to Twittermail, which publish it on Twitter. And Twitter will automaticly publish it on your homepage.
See a working axample at http://CharlieBloom.com. Only the 3 latest (customizeable) Tweets are visible, click on "Follow me on Twitter" to se "My position ....." and a Google Maps-link. Positions are updated on my website 2-3 minutes after I have sent them.
Best regards,
Charlie Bloom
Yes, but the accuracy is pretty bad. I just built a web form that posts GPS settings from the watchPosition() function to my database and then maped the results. While paddling down a local river it got only two of seven posts correct. The rest were outside the river, and two of those were about a mile away! I'm now looking for a better solution.
Here's the code I use to update the form fields:
<script type="text/javascript">
function getGPSLocation()
{
if(navigator.geolocation)
{
navigator.geolocation.watchPosition(onGeoSuccess);
} else {
alert("Your browser or device doesn't support Geolocation");
}
}
function onGeoSuccess(position) {
document.getElementById("Latitude").value = position.coords.latitude;
document.getElementById("Longitude").value = position.coords.longitude;
}
</script>
And this is the form. Update to suite your needs.
<form>
<img src="spacer.gif" OnLoad="getGPSLocation();">
<input type="Text" name="Latitude" id="Latitude" value="">
<input type="Text" name="Longitude" id="Longitude" value="">
</form>