Redirecting app to webpage - c#

So i'm making this app for Windows Phone 8, and what it basically does is redirect to a webpage, how do I do so? Because what I did is add the code and when I start the app, it redirects to the browser and webpage, but if i press the back button, it goes back to the blank "MainPage.xaml". How do I remove the main page from appearing? Such as once the browser is launched, the app auto-quits

Two options:
Use the WebBrowser control (the default when you use the Windows Phone HTML 5 App template). In this case, you're not redirecting, you're hosting the browser as part of your app, and can then also take advantage of other platform features within the app.
Use Application.Current.Terminate in Windows Phone 8. For instance, the following opens the app, immediately starts up the browser, and then quits the XAML app leaving the browser on the screen.
// Constructor
public MainPage()
{
InitializeComponent();
Launcher.LaunchUriAsync(new Uri("http://www.cnn.com", UriKind.Absolute));
Application.Current.Terminate();
}
Though this is possible, it doesn't seem all that useful and I'm doubtful it would pass certification since all it does is launch a browser (but I'm presuming this is just part of where you're going with this app?)

Related

How to launch UWP app from the browser link?

I am following this https://csharp.christiannagel.com/2016/11/15/deeplinking/ to support deep-linking in my UWP app.
Everything works fine if I click the link from some other app(my UWP app is automatically launched on the click of the link) but if I click the link from the browser, it stays on the browser itself.
I need a way to navigate to my app from the browser just like it is done in apps like Microsoft Teams etc
Microsoft teams example:-
user receives email
when the user clicks on the link

Schema URIs in Windows Store Apps vs Chrome

I'm developing an app for Windows 8.1 called myTrip and I'm implementing my custom scheme URI for the app. I want this URI : mytrip:place:/m/0942y1 to open my app and navigate to a place with that ID. I have the logic done, it works fine if I run it from Windows + r. I want to distribute this uris in a facebook page, and when a user clicks on it, the app will open and the place shown. It's more or less the same thing that the windows store web page of your app does:
http://apps.microsoft.com/windows/en-us/app/mytrip/ae689d16-f349-4596-8bc7-e0eeab87ec24
This works in IE and Chrome, the schema that opens the store app is this:
ms-windows-store:PDP?PFN=19185FernandoUrkijoCerced.MyTrip_q1p7rzex4ekjr
If you copy and paste it on Chrome, and you have Windows 8, the app store will open. But, if I try with my custom URI:
myTrip:place:/m/0942y1
It only works on IE, not on Chrome. Why the Windows app store schema URI works with Chrome and not with my schema? Any ideas or hacks to bypass this problem?
Thanks you.
Chrome does not automatically recognize custom protocol handlers. Firefox will recognize when you are trying to use a protocol handler and offer to create a protocol handler definition for you. IE recognizes them.
On top of this, Chrome by default excludes protocol handlers it doesn't know.
In order to add your app's handler to Chrome:
With Chrome Closed
Navigate to "C:\Users\%Username%\AppData\Local\Google\Chrome\User Data"
Edit the file "Local State" with Notepad (or Notepad++)
Go down to the section marked "protocol_handler". You can also search for "ms-windows-store"
Add a line in "excluded schemes": "myTrip": false,
Save the file
Start Chrome
You should be able to use your protocol inside Chrome now.

How to allow blocked content in an embedded Webbrowser in c#?

I'm developing a c# application that embeds the Webbrowser control. I create the Website dynamically and use NavigateToString() to display it. I'm on Windows 8 with IE10.
Now my Problem is: Javascript won't execute. For example I added a link that calls alert and another one that calls reset() on a form. Both do nothing. I believe it has to be some security issue because when I say the generated page and open the file manually in IE10 and click one of those links, I get a popup at the bottom that says "Internet Explorer restricted this Webpage from running scripts or ActiveX controls." and a "Allow blocked Content"-button. If I just Close the popup, nothing happens, if I click "Allow blocked Content" the JavaScript works fine.
How can I enable JavaScript in the embedded Webbrowser?
How are you accessing this local website? is it localhost? you need to make the url security friendly so it doesn't get blocked, give it a url http:// localhost:someport instead and it should work

Close silverlight applications and redirect to parent applications

My company is developing a Silverlight application which we then give to our clients who integrate it with their product. You can log into the application by going through a form or using a URI where you pass some needed data. If you provide false data (i.e. you can not be authenticated) you get a message and the applications closes. Then the user just has a blank (white) screen in front of him. We don't want that to be the case any more. Instead we would like to redirect to the calling page (where the user clicked the link to start the app).
So if for example user A has his application open on http://hisdomain.com/work and clicks on a link that redirects him to our Silverlight app where the authentication fails we would like to show him a message (this is happening at the momment) and then redirect him back to http://hisdomain.com/work.
Any ideas how to do this?
I am still in R&D about this so I have not much of an idea about it. The only thing that came to my mind was to pass in the calling URL along with the rest of the data.
Thanks.
If you can pass the starting URL into the Silverlight app with the startup params, you can redirect back with this:
System.Windows.HtmlPage.Window.Navigate(new Uri("YourStartupUrl.aspx", UriKind.Relative));

Redirecting to device settings

Say I have a mobile optimized website which runs with a lot of javascript on it to create awesome effects, and a user enters the website via a mobile browser which doesn't have javascript activated.
Is it then possible to (through a button click) redirect that user to his/hers browser settings?
You need to have JavaScript activated in order to browse this site properly.
Click here to change your settings
In principle, you can create an intent: URL that references an ACTION_SETTINGS Intent, though I have not tried this. Off the top of my head, the simplest way to construct that URL is to generate a scrap Android project and call:
Log.d("Something", new Intent(android.provider.Settings.ACTION_SETTINGS).toUri(Intent.URI_INTENT_SCHEME));
then check LogCat for the URL that you would put in the Web site. Of course, this URL will only work on Android devices.
I only know Windows Mobile (and there, only up to v6.1), but I would guess your clients would have to have some app of yours prior installed to access features of the device itself.
If websites could access a device's features, it would be viewed as a virus.

Categories

Resources