Set Up The Authentication Manager

In order to redirect an authenticated user from the Mobile Authenticator app back to your referring service, you must first add the following extension to WMAppManifest.xml. The protocol name should be the letters "lk" followed by your Service Key.

Example

<Extensions>
    <Protocol Name="lk1000000000" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>
Next, register your app login page as a fast resume page by adding ActivationPolicy="Resume" to your
DefaultTask WMAppManifest.xml entry

Example

<Tasks>
    <DefaultTask  Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume" />
</Tasks>

In the InitializePhoneApplication method of your app's App.xaml.cs file (just after RootFrame.Navigated is assigned) set the RootFrame.UriMapper property equal to a custom URI mapper class (AssociationUriMapper()).

Example

RootFrame.UriMapper = new AssociationUriMapper();

Finally, add the class definition for the AssociationUriMapper to your project. Below is the class definition. Be sure to replace <serviceKey> with your Service Key.

class AssociationUriMapper : UriMapperBase
{
    private string tempUri;

    public override Uri MapUri(Uri uri)
    {
        tempUri = System.Net.HttpUtility.UrlDecode(uri.ToString());

        if (tempUri.Contains("lk<serviceKey>:response"))
        {
            string parameters = tempUri.ToString().Split(new string[] { "lk<serviceKey>:response?" }, StringSplitOptions.None).Last();

            var dict = parameters.Split('&').Select(p => p.Split('=')).ToDictionary(p => p[0], p => p.Length > 1 ? p[1] : null);

            string message = dict["message"];

            if (message.Equals("authError"))
            {
                LaunchKeyManager.LKAuthenticationManager.Instance.appErrorOccured();
            }

            return new Uri("/MainPage.xaml", UriKind.Relative);
        }

        return uri;
    }
}

In the InitializePhoneApplication method of your app App.xaml.cs file (just after RootFrame.Navigated is assigned) set the RootFrame.UriMapper property equal to a custom URI mapper class (AssociationUriMapper()).

User Contributed

LaunchKey links to user contributed code as a resource to its community. LaunchKey does not in any way guarantee or warrant the quality and security of these code bases. User contributed code is supported by the creators. If you do find a link from the site to user contributed code that is malicious or inappropriate in any way, please report that link to LaunchKey immediately and we will investigate the claim. Submit any issue to LaunchKey support at https://launchkey.com./support. ×