private AppLink CreateAppLink(List<PlatformProperty> platforms) { var platformDictionary = new Dictionary<Platform, Target>(); platformDictionary[Platform.WindowsPhone] = new Target{Platform = Platform.WindowsPhone}; platformDictionary[Platform.Windows] = new Target {Platform = Platform.Windows}; platformDictionary[Platform.Universal] = new Target {Platform = Platform.Universal}; AppLink resultLink = new AppLink(); resultLink.Targets = new List<Target>(); ; foreach (var platform in platforms) { //platformDictionary[platform.Property] = platform.Content; switch (platform.Property) { case "fb:app_id": break; case "al:windows_phone:url": platformDictionary[Platform.WindowsPhone].Uri = platform.Content; break; case "al:windows_phone:app_name": platformDictionary[Platform.WindowsPhone].Name = platform.Content; break; case "al:windows:url": platformDictionary[Platform.Windows].Uri = platform.Content; break; case "al:windows:app_name": platformDictionary[Platform.Windows].Name = platform.Content; break; case "al:windows_universal:url": platformDictionary[Platform.Universal].Uri = platform.Content; break; case "al:windows_universal:app_name": platformDictionary[Platform.Universal].Name = platform.Content; break; default: continue; } resultLink.Targets.Clear(); foreach (var key in platformDictionary.Keys) { resultLink.Targets.Add(platformDictionary[key]); } } // the order of preference in the app links is: // 1. Platform // 2. Universal // 3. Web // 4. return what the user passed in return resultLink; }
async public static Task <bool> NavigateAsync(AppLink appLink) { string navigationLinkUrl = String.Empty; if (appLink != null) { foreach (var target in appLink.Targets) { #if WINDOWS_PHONE if (target.Platform == Platform.WindowsPhone) { navigationLinkUrl = target.Uri; break; } #else if (target.Platform == Platform.Windows) { navigationLinkUrl = target.Uri; break; } #endif } } if (!String.IsNullOrEmpty(navigationLinkUrl)) { // If we found a platform specific app link, launch it await Windows.System.Launcher.LaunchUriAsync(new Uri(navigationLinkUrl)); } else { // no platform specific applink was found, launch the fallback url await Windows.System.Launcher.LaunchUriAsync(new Uri(appLink.FallbackUri)); } return(false); }
async public static Task<bool> NavigateAsync(AppLink appLink) { string navigationLinkUrl = String.Empty; if (appLink != null) { foreach (var target in appLink.Targets) { #if WINDOWS_PHONE if (target.Platform == Platform.WindowsPhone) { navigationLinkUrl = target.Uri; break; } #else if (target.Platform == Platform.Windows) { navigationLinkUrl = target.Uri; break; } #endif } } if (!String.IsNullOrEmpty(navigationLinkUrl)) { // If we found a platform specific app link, launch it await Windows.System.Launcher.LaunchUriAsync(new Uri(navigationLinkUrl)); } else { // no platform specific applink was found, launch the fallback url await Windows.System.Launcher.LaunchUriAsync(new Uri(appLink.FallbackUri)); } return false; }
private void AppLinkObtainedEvent(AppLink appLink) { // do something with applink int x = 10; }
private AppLink CreateAppLink(List <PlatformProperty> platforms) { var platformDictionary = new Dictionary <Platform, Target>(); platformDictionary[Platform.WindowsPhone] = new Target { Platform = Platform.WindowsPhone }; platformDictionary[Platform.Windows] = new Target { Platform = Platform.Windows }; platformDictionary[Platform.Universal] = new Target { Platform = Platform.Universal }; AppLink resultLink = new AppLink(); resultLink.Targets = new List <Target>();; foreach (var platform in platforms) { //platformDictionary[platform.Property] = platform.Content; switch (platform.Property) { case "fb:app_id": break; case "al:windows_phone:url": platformDictionary[Platform.WindowsPhone].Uri = platform.Content; break; case "al:windows_phone:app_name": platformDictionary[Platform.WindowsPhone].Name = platform.Content; break; case "al:windows:url": platformDictionary[Platform.Windows].Uri = platform.Content; break; case "al:windows:app_name": platformDictionary[Platform.Windows].Name = platform.Content; break; case "al:windows_universal:url": platformDictionary[Platform.Universal].Uri = platform.Content; break; case "al:windows_universal:app_name": platformDictionary[Platform.Universal].Name = platform.Content; break; default: continue; } resultLink.Targets.Clear(); foreach (var key in platformDictionary.Keys) { resultLink.Targets.Add(platformDictionary[key]); } } // the order of preference in the app links is: // 1. Platform // 2. Universal // 3. Web // 4. return what the user passed in return(resultLink); }