I'm trying implement Facebook Login using the Facebook C# SDK but I'm having an issue returning back to the app when a login has been successful.
I have followed all the steps in this tutorial but i'm having an issue.
I have created a custom UriMapper that should go back to the MainPage.xaml when launched.
public override Uri MapUri(Uri uri)
{
if (uri.AbsoluteUri.Contains("/Protocol?encodedLaunchUri=msft"))
{
return new Uri("/MainPage.xaml", UriKind.Relative);
}
return uri;
}
My problem is the page refreshes and all my data in forms and text boxes gets removed.
Is it possible to "Resume" an app via URI instead of restarting it?
I've tried adding the tag below in the manifest but this does not work.
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume"/>
The part that you added in the manifest file enabled Fast App Resume, which means that your application won't be relaunched as a new instance if it is sitting in the background. But this doesn't guarantee that your input boxes will get their data restored. For this, you need to preserve the page state and restore it when the app resumes. Read more about this here.
Related
Using DotNetBrowser in WPF app in Windows 10. When navigating to certain pages that typically save user data and use it in subsequent loads to restore your settings, it doesn't seem to be happening.
See example code here of a very simple implementation. If I use it to browse to Amazon's site and login, after closing and reopening app, I'll need to login again -- in a normal browser like Chrome, it retains my login. Is something missing in the code to enable this similar behavior?
To make it work, I had to set UserDataDirectory when creating engine:
engine = EngineFactory.Create(new EngineOptions.Builder
{
RenderingMode = RenderingMode.HardwareAccelerated,
UserDataDirectory = $"{Environment.ExpandEnvironmentVariables("%AppData%\\MyApp\\Chromium\\User Data")}",
LicenseKey = ConfigurationManager.AppSettings["DotNetBrowserLicenseKey"],
}
.Build());
So i'm opening a standalone Unity app from a UWP store app. In my UWP app I use the unity WSA class to launch the custom uri I created.
Example:
In the register I created a custom uri called test:
In UWP app c# I use:
string uri = #"test:";
// Launch the URI
Launcher.LaunchUri(uri, true);
This works fine. The app launches. However if the app does not exist it pops up a dialogue to ask me with what I want to open it. Can I check this also while launching? So if the user has the app not installed I give the user feedback? I tried pretty much every class available for Unity and uri's etc. None of them do what I need. I had high hopes for a few, but all they did was tell me if the URI i entered are valid uri formats, rather then checking if it can actually open the app.
EDIT: Also, what's the difference between Launcher.launchURI and Application.OpenURL?
Application.OpenURL opens a url in the default browser, while Launcher.LaunchUri starts the default app associated with the specified URI.
And no, from the UWP app you just can’t query the system whether the URI is registered or not, there is no such API.
And LaunchUri just returns false if no app is launched, but at that time an error dialog is already prompted, so checking the return value of LaunchUri is not a solution either.
I'm developing an UWP app that is using webview and client certificate to login. I have a simple login frame that navigates to Webview frame. When I click login I'm navigated to webview and asked to select one of two certificates that I have in my certificate store. I select first one and I'm successfully logged in. I log out from webview application and navigate to login frame. Now I want to login again and choose a different certificate but I always log in with the first one I have selected. If I close app and start it again, it works like I want it should.
I have tried deleting AC\Microsoft\Crypto, AC\Microsoft\SystemCertificates and AC\Microsoft\CryptnetUrlCache but it doesn't work. I have also tried creating new instance of webview every time I navigate to webview frame but that also doesn't work.
Can anyone help me
Looks like you forgot to clear cookie. Try to clean it with the following method.
Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync();
Also check stackoverflow answer Clear all cookies from WebView
I have this weird problem my website won't cache the mainsite!
Here is a little overview about what I am trying to do
The first page that is being loaded is the
[DidTheUserLoggedInBefore?.html]
which checks if the user already has logged in or not depending on that result the user will be redirected to
either [LOGIN.html] or [MAINPAGE.HTML]
pretty simple!
But here comes the problem when the user restarts the app in Offline mode the App should redirect immediately to the mainpage (assuming the previous login was a success).
But that doesnt happen at all.
Instead the [DidTheUserLoggedInBefore?.html] from cache was called (which is correct) and starts loading the mainpage which isnt in cache which results in a whitescreen aka my error.
So how do I get my App to cache the Mainpage?
I've tried setting CacheSize to 100, but that didn't changed a thing :(
You can't check if the user has logged in with a .html file... You need some sort of server side language to set a cookie... Anyway this isn't much clear, is your "app" just a webview?
I couldn't let the webview cache more than 2 (simple) webpages...
WebView ignores he offline.manifest.php file too ...
I need to launch a browser, do some work and then make the browser navigate to a URL (in that order).
The first part is of course simple and I have a Process object. I am at a loss as to how to later direct it to the target page?
How do I treat the Process as a browser and make it navigate to the desired page?
Any help, pointers, code snippets appreciated.
Instead of launching the browser & then navigating to the page, just tell the OS that you want to run the URL. Windows will pick the correct browser, and navigate the user to the given URL.
System.Diagnostics.Process.Start("http://www.StackOverflow.com");
If you don't need to do this in production, you could use a testing library such as WatiN to do this:
using WatiN.Core;
//Placeholder page to launch initial browser
IE ie = new IE("http://www.google.com");
DoSomeWork();
//Now navigate to the page you want
ie.GoTo("http://stackoverflow.com");
My first instinct for this question was DDE, but it appears that has been decommissioned in Windows Vista so that is no good. Shame, as it was the only consistent mechanism in Windows for Interprocess Communication (IPC)...oh how I miss Arexx on the Amiga.
Anyhow, I believe the following will work but unfortunately, due to the way it works, it launches Internet Explorer irrespective of the configured browser.
If your application has a Form, then create a WebBrowser control on it. Set this to non-visible as we are only making use of its as a launching device rather than to display the web page.
In code, at the point where you want to show a web page, use the following code:
webBrowser1.DocumentText = "window.open('How to launch a browser and later direct it to a page?', 'BananasAreOhSoYummy');";
What this does is to tell the WebBrowser control, which is just the IE in disguise, to open a new window called 'BananasAreOhSoYummy'. Because we have given the window a name, we can use that line repeatedly, with different URLs, to change the page in that particular browser window. (A new window will be opened if the user has happened to close it.)
I will have a think about an approach that honours the user's default browser choice.
If you don't need the actual instance of IE, you can use the System.Windows.Forms.WebBrowser control.
I think instead of sending the browser a url you could send it javascript that would run and direct the browser to a site.
Not sure if this would work but I see no reason why it wouldn't