void CreateAndDisplayShortLink(DynamicLinkOptions options) { if (kDynamicLinksDomain == kInvalidDynamicLinksDomain) { DebugLog(kDynamicLinksDomainInvalidError); return; } var components = CreateDynamicLinkComponents(); DynamicLinks.GetShortLinkAsync(components, options).ContinueWith((task) => { if (task.IsCanceled) { DebugLog("Short link creation canceled"); } else if (task.IsFaulted) { DebugLog(String.Format("Short link creation failed {0}", task.Exception.ToString())); } else { ShortDynamicLink link = task.Result; DebugLog(String.Format("Generated short link {0}", link.Url)); var warnings = new System.Collections.Generic.List <string>(link.Warnings); if (warnings.Count > 0) { DebugLog("Warnings:"); foreach (var warning in warnings) { DebugLog(" " + warning); } } } }); }
private Task <ShortDynamicLink> CreateAndDisplayShortLinkAsync(DynamicLinkOptions options) { if (kDomainUriPrefix == kInvalidDomainUriPrefix) { DebugLog(kDomainUriPrefixInvalidError); var source = new TaskCompletionSource <ShortDynamicLink>(); source.TrySetException(new Exception(kDomainUriPrefixInvalidError)); return(source.Task); } var components = CreateDynamicLinkComponents(); return(DynamicLinks.GetShortLinkAsync(components, options) .ContinueWithOnMainThread((task) => { if (task.IsCanceled) { DebugLog("Short link creation canceled"); } else if (task.IsFaulted) { DebugLog(String.Format("Short link creation failed {0}", task.Exception.ToString())); } else { ShortDynamicLink link = task.Result; DebugLog(String.Format("Generated short link {0}", link.Url)); var warnings = new System.Collections.Generic.List <string>(link.Warnings); if (warnings.Count > 0) { DebugLog("Warnings:"); foreach (var warning in warnings) { DebugLog(" " + warning); } } } return task.Result; })); }