C# / JavaScript local code in hosted web apps on Windows 10 - javascript

We have a fully functional website. Now we want to develop a windows 10 app and since hosted web apps seem the quickest way we want to explore that option. I have created hosted web app for our site but can I embed any local code in the app that can communicate with code website. Like can I change the user agent string to recognize request is from hosted web app? Can I access camera from local code? I was unable to find any resources on these. Or do I have to use a webview in UWP app and load website in it? Any suggestions?

Check this page first. If your url is defined within the app’s bounds(ACURs), then you can call windows runtime api which can help you acess to camera. But I didn't find any windows runtime API which can help you change your user agent.

Related

UWP Secured file location for Database

currently I'm working with an application using ionic framework and testing it as of now as UWP application.
May I know where should I put my sqlite database file where the other window users can't see or access it except the application that created it?
Thank you.

alternative of URL scheme for launching application in ios from another application?

Target Application is not having any URL scheme, and i want invoke it with my application.
I also want to redirect to Apple store if the user doesn't have that application installed.
Please tell me if there is any other way to open an application from Cordova plugin or JavaScript. Thanks in advance.
Sorry. But unless you have a jailbroken device, there's no way to open another app other than via URL scheme, i.e. (Swift): UIApplication.open(_:options:completionHandler:)
This is so by intention since Apple wants the apps sandboxed and therefore strictly limits the ways apps can interact. Launching via URL is the only way they permit app launching.

Get userID of current windows user in my website via JavaScript

I have a feature in my upcoming web project where I will have to get the UserID/Email ID of the user currently logged in to the machine/PC. Target OS is Windows 10 and logins to the machines are done via Smart Card only. User Data is stored inside MS-AD.
This UserID will be used passed further for Authorization and load the app in browser. The target browser is IE and Chrome.
Is there a way i can fetch the EmailID/UserID of the User logged in via Smart Card to system in Javascript?
ADDITIONAL INFO: The website is setup in private environment. There is no public URL to access the webapp from outside Intranet. The client and backend code is hosted inside VM in Cloud. In nutshell, the is all sitting in private environment in Azure.
Thanks!
Not with JavaScript. JavaScript is run inside the browser container, and more specifically run inside your current webview. Letting JavaScript get access to settings and data on the local machine be a nightmare if phishing, malware and virus sites.
If you know which computers will run your website you could create an application with a server that's running idle on the machine, much like how Spotify's client is doing (the windows client can take commands from the webpage).
The application/server could then try to get the EmailID/UserID from the computer, and then having the server running on some specific port, your JavaScript could then use AJAX-requests to communicate with the local machine from the browser.
I could get the Windows Logged in user using the ActiveX script in IE.
var WinNetwork = new ActiveXObject("WScript.Network");
alert(WinNetwork.UserName)
Will this be a good approach to solve this issue?

Offline only app for smartphones in Javascript

Can I write a offline only application using HTML, CSS and Javascript ( + AngularJS) for mobile devices (for example with cordova), so the user won't need any internet connection to start and use the application. As far as I know cordova just creates a webview and I wonder now, how will the page be shown, when there is no hosting...
Imagine a simple calculator or todo app which works just offline.
Is this possible? Or do I have other ways except cordova...
The pages are hosted inside the app. The html,js,css files are packed inside the apk. When a user install the app it download the pages within the app. And webview access the pages locally. So you can make app both online and offline.
suppose the android project directory. Html pages are kept in the directory
yourprojectfolder\android\assets\www
And in the java file at the app start it just create the webview and call the index.html page. Now if you need any device function like notification / geolocation you can use them using plugin. Plugins are those that creates bridge between html and java files.
Also several databases are available for phonegap development. So you can store data locally. Go through the documentation for more and create & understand the structure.

How to run a script from the Web in a Windows 8 app?

My organization already developed iOS and Android apps, and is starting to develop an app for Windows 8. In case it matters, the app is using Phonegap a.k.a. Cordova.
On the existing apps, the user downloads a very "slim" app from the store, containing a minimal HTML page. The user logs into a server, and then script tags are dynamically added pointing to locations on that server. Similar to web apps, scripts are downloaded to the client and then executed.
Windows 8's new security model blocks this behavior. Since the app runs in the local context and the script is on the web, I get the error "An app can’t load remote web content in the local context."
Is there a way to get around this restriction?
I'm open to "creative" suggestions and hacks, up to a point. I've already tried a few things, such as fetching a script with plain XHR calls and then injecting the response to a pre-defined script tag. Windows blocked this and all other attempts.
I also considered rendering everything in an iframe with a "ms-appx-web:" scheme (learned about this scheme here, "Schemas and contexts" section). This might allow me to load remote scripts, but would prevent code from accessing APIs of the locally-running JavaScript code -- Cordova and Windows Runtime. This access is necessary for my app. If there's a way to access Cordova and Windows Runtime from the web context, that might be useful too.
I very much doubt it.
The whole point of the MS Windows Store certification model is that they can test your code for malware/ crashes. If you can change the code on the fly, you could ship a perfectly harmless app, have it certified by MS, and then change it to something dreadful after the user installs it.

Categories

Resources