Check if any app can handle URI scheme - windows-phone-8

I'm creating a Windows Phone 8 app (Store apps) in which I will have some links for the user to open other apps.
My goal is to hide or show only the links for which I have apps that can handle them.
For instance, I have a link for
mymoneyapp://user=123
and another for
mymusic://user=123
So, if I have an app that can handle the mymoneyapp scheme I want the link to show if not then I hide it.
The only why I found to test this is using
LauncherOptions options = LauncherOptions();
options.FallbackUri = new Uri("http://myfallbackpage.com");
Launcher.LauncherUriAsync(new Uri("mymoneyapp://user=123"), options);
But in this case I get my fallback Uri launched if no app can handle that schema.
Is there any way just to test if an app can launch it without actually do it?

There is no API for this on Windows Phone 8. Windows 10 adds Launcher.QueryUriSupportAsync to allow checking if there is a handler before launching it.
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.launcher.queryurisupportasync.aspx

Related

Single sign on single native client windows phone using ADAL

We have a windows phone native app (and building for android, iOS also) which uses ADAL to get token for ex:graph. ADAL is asking for credentials for the first time.
Now inside of this native app on some frame we have a WebView control which launches another website (our own) or say login.microsoftonline.com which is asking to login again. How can I achieve SSO in this case and don't prompt login for the second time. Is there a way I can reuse the same WebView control which ADAL is using so the cookies will be shared. What are the alternatives in achieving this.
ADAL on Windows Phone does not use a WebView. It uses the WebAuthenticationBroker (WAB), a system API specifically designed to keep the cookie jar used during authentication isolated form the app itself. That prevents apps from using cookies to silently access protected resources without the user knowledge, while at the same time pooling the cookie jar across all the apps that use the WAB for authentication.
Furthermore: there is no native app to browser SSO mechanism today.
Hence, as of today there is no way of sharing SSO state between the app itself and a WebView hosted by the application.

AdMob for Windows Phone 8 FailedToReceiveAd NetworkError

I need to add AdMob banner to my app. But I catch FailedToReceiveAd event with NetworkError message on emulator and on device. Example from official site behave the same way. WebBrowser and other network tasks work with network good.
Plese help, because i can't find any solutions of this proplem.
Select the mandatory and optional capabilities for your app. You can modify your app's capabilities by opening WMAppManifest.XML and selecting the Capabilities tab.
Also check adRequest.ForceTesting = true; it must be false

Auto-launching DailyMotion Windows Phone from another App

I have read about Auto-launching apps from another app on Windows Phone. I have a app that shows some videos, these videos are mainly from DailyMotion. Now my Question is if there is any possibility to check, if DailyMotion App is installed on my Phone, than open this video in this DailyMotion app instead of browser.
You can use custom URL to launch the dailymotion app. For example, using the line of code
string dailyUrl = "dailymotion://myurl";
Windows.System.Launcher.LaunchUriAsync(new Uri(dailyUrl));
It will automatically open the dailymotion app if it is installed on the phone, but otherwise it will probably perform nothing. So with the previous answer explaining how you might check if the app is installed, and this piece of code, you might be able to perform what you need :)
You cannot get the list of applications that are installed on the Windows Phone that are published by someone other than the publisher of the calling application.
There is a way, however, to get the list of applications that are installed on the device and are originating from the publisher of the caller ape.
Have a look over here
IEnumerable<Package> apps = Windows.Phone.Management.Deployment.InstallationManager.FindPackagesForCurrentPublisher();
apps.First().Launch(string.Empty);

How do I structure my code to run a XAML page in a WinRT app and "return" a result?

I'm currently building a universal app for Windows 8.1 and Windows Phone 8.1.
In Windows Runtime, the file picker has a very easy to use API that looks like this:
StorageFile file = await openPicker.PickSingleFileAsync();
It treats user input as an asynchronous operation that can be awaited. In this instance, if a user cancels, null is returned, but you could imagine an exception being thrown if the user cancels.
I was wondering if there was some way to create a page so that I can create a similar API. Specifically, I am doing OAuth 2.0 authentication with a hosted service, and I want to send the user to the authentication page hosted in a WebView and return the code for requesting access tokens if the operation is successful or throw an exception if the user does not authorize my application.
For example:
var authentication = new AuthenticationAccess();
string code = await authentication.RequestAuthorizationAsync();
The call would swap out the Page in the Frame with the Page containing the WebView's, the user would be able to authenticate and then control would return back to the calling function and the page swapped back to the original page.
I'm kind of swimming in Windows 8.1 C#/XAML documentation. From what I understand, there is a global Window object that hosts a Frame object which can have its content swapped out with the different Pages in the application. Having done some Android development, I'm familiar with the Activity model, where essentially different pages can be initiated through intents and can propagate results back up to the Activity which launched it. With this model, it seems like it would be easy to wrap this process in the model I described, but I'm a little confused of how to do the same thing in Windows. Would I need to stand up significant architecture to achieve this pattern?
Is there a simple answer to this, or am I in over my head?
Have you checked out the WebAuthenticationBroker yet? Perhaps that could turn out to be an easy solution to your problem.
Otherwise - you can use TaskCompletionSource to set up the authentication task that you can await, but I'd try to avoid navigating to other pages for your authentication dialog since navigation events could mess up your states and break whomever is waiting for the authentication to complete. A dialog overlay of some sort might be a better idea.

How to open links using a chrome app? (Similar to how Android prompts you on what app you want to use to handle certain URLs)

I have a chrome app which displays data pulled from website A.
If a user has the app installed, and is on website A, how can I make the chrome app detect that the user is on website A and then prompt the user to open website A in the chrome app?
I'm trying to mimic how Android does this if you try to open a Google Play Store URL for example.
Thanks in advance,
Dimitry
Your app needs to define a webRequest (part of permissions) in the manifest file. You might use the blocking response to then handle all the stuff yourself.