In the AppConKit, you can give your users the option to configure a Servername, port and path in the Settings that this Apps connects to. Can I somehow access these configured settings in the Javascript code?
My use-case is that I have a logo image sitting on the server the app is connecting to, and would like to show this logo based on the server url.
Any Idea?
Makes sense, but that's not a setting that is easily accessible (yet).
You can access the settings via the device switch:
var hostname;
var port;
var path;
if (vMobileController.device().isAndroid()) {
hostname = vKVS.value("Weptun_Hostname");
port = vKVS.value("Weptun_Port");
path = vKVS.value("Weptun_URL_Path");
} else {
hostname = vKVS.value("server_url");
port = vKVS.value("server_port");
path = vKVS.value("server_endpoint");
}
if (hostname.substring(0,4)!="http") {
hostname="http://"+hostname;
}
var vUrl = hostname+":"+port+"/"+path+"/images/Logo.png";
I talked with the developers tho, and it would make sense to access this via direct Javascript API. I'll see that it's added to the roadmap!
Related
I'm adding PWA support to a web app. I want to add a back-button to the interface for iOS when the app is used as a PWA but not when used in the old fashioned way in Safari (or another browser).
I know I can detect this via JS - so I could just show/hide the back-button at runtime, but I would like to know if there is any way to detect in on the server-side already (apache/php). I guess there will be more use-cases coming up to serve slightly different content.
I guess I could set a cookie, but I want to make sure there is nothing more easy/obvious to use, some new header for example.
Found one more way in the meantime to do it, apart from cookies. Sending a custom http header via a service worker.
app.js
navigator.serviceWorker.register('/sw.js').then(registration => {
if(registration.active) {
const sw = registration.active;
sw.postMessage({
'is_pwa': is_pwa()
});
}
});
sw.js
var myHeader = new Headers(event.request.headers);
if (is_pwa) {
myHeader.append('ISPWA', is_pwa ? is_pwa : "");
}
var config = {
headers: myHeader
};
if(navigator.onLine !== false) {
event.respondWith(fetch(request).catch(function(error) {
fetch(request, config).catch(function() {
[...]
php
var_dump($_SERVER['HTTP_ISPWA']);
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);
To summarize the problem, I have several PDF files on my computer that contain links to other pages. Those links, however, direct you to the local filesystem instead of the internet (i.e. clicking the link opens the browser and takes you to file:///page instead of http://domain/page).
Getting these files modified to include the full URL is not an option. My question is almost identical to the question I asked a year and a half ago. The difference is that I need to port my existing extension (made with the Firefox SDK) to the new WebExtensions API for Firefox (same as Chrome extensions).
There are methods available for redirection, such as
browser.webRequest.onBeforeRequest.addListener(
redirect,
{urls:[pattern]},
["blocking"]
);
but that only accepts http:// and https:// URL patterns.
I am currently trying to use the following code:
var id;
browser.tabs.onCreated.addListener( details => id = details.id )
browser.tabs.onUpdated.addListener( (tabId, changeInfo, tab) => {
var url = changeInfo.url;
if (tabId == id && url.includes("file:///")) {
url = url.replace("file:///page", http://domain/page");
browser.tabs.update(
id,
{ url: url }
);
}
});
Unfortunately, I have the same fundamental issue as with my original problem, resulting in the onUpdated listener not firing (or if it does fire, it's not because of a URL change). But regardless of the listener used (e.g. onCreated, onActivated, etc.), I get about:blank for the URL.
I have tried injecting code to change the value of the address bar, but that doesn't seem to work either:
browser.tabs.executeScript( {
code: "window.location.href = window.location.href.replace('file:///', 'http://domain/')"
});
Thanks for any help!
redirectUrl : chrome.extension.getURL("hello.html")
Worked for me
I am trying to understand how I should configure a web site (ASP.Net) that need to pass the user credential and get some mail things
I get different kind of errors depending on the app pool configure,
What is the complete way to do it? I mean code + Configuration ;o)
I don't want to write the user and password but get them through the windows authentication
Thanks
code:
Service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
{
Url =
new Uri(
"https://xxx/yyy.asmx"),
//UseDefaultCredentials = true doesnt help
};
var view = new ItemView(1820);
// Find the first email message in the Inbox that has attachments. This results
FindItemsResults<Item> results = Service.FindItems(folderName, view);
//Here I get the error 401
Take a look at Get started with EWS Managed API client applications, it covers the basics to get you up and rolling. Note that when you use UseDefaultCredentials, you have to be on a domain joined machine, with the user logged in, and you must be targeting an on-prem server. We tested that scenario out and the following code works in that scenario.
using System;
using Microsoft.Exchange.WebServices.Data;
namespace HelloWorld
{
class Program
{
static void Main()
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
//Replace the URL below with your own, but using AutoDiscover is recommended instead
service.Url = new Uri("https://computer.domain.contoso.com/EWS/Exchange.asmx");
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox,
new ItemView(1));
}
}
}
If that doesn't work for you, then you might want to try using impersonation. See this thread, where I think they've got a similar situation . More information about impersonation is on MSDN: Impersonation and EWS in Exchange.
I'm trying to get all the photos from a user's profile and i need to add that to the extended permissions of my Facebook MVC C# app.
I've tried using the following code below but i can't get it to work, i just get:
"This webpage has a redirect loop"
Does anyone have any ideas on how to add extended permissions?
[FacebookAuthorize(LoginUrl = "/Account/Login", Permissions = "user_photos")]
public ActionResult Profile()
{
var client = new FacebookWebClient();
dynamic photos = client.Get("me/photos");
dynamic me = client.Get("me/photos");
ViewBag.Name = me.name;
ViewBag.Id = me.id;
return View();
}
I'd like someone to correct me if i'm not right, but, extended permissions are specified either on the login button, or the permissions button.
For example, I have the login button on my Default.aspx page:
<fvk:loginbutton id ="loginbutton1" runat="server" OnConnectCalled="OnLogin" Permissions="email,user_birthday,publish_stream,user_photos" Size="small" />
That is where I specify what permissions my app needs. And after that I can specify inside my code, what info I need to retrieve in a specific moment. Default.aspx.cs.
var client = new FacebookWebClient();
dynamic photos = client.Get("me/photos");
dynamic me = client.Get("me/photos");
ViewBag.Name = me.name;
ViewBag.Id = me.id;
This way, when the user first logs into your app, he gives the requested permissions. Then afterwards, you can use his info / photos anyway you want in your code.
I just did that exact same thing using this:
[CanvasAuthorize(Permissions = "user_photos,publish_stream", CancelUrlPath = "/Home/NoPermission", ReturnUrlPath = "/Photos/Upload")]
I'm not sure the difference between FacebookAuthorize and CanvasAuthorize. What might help is setting the REturnUrlPath. I did it because I'm working locally on a virtual directory and it wasn't redirecting correctly after authentication.