Example #1
0
        /// <summary>
        /// Initialize SDK
        /// </summary>
        /// <param name="appId">Your VK app ID.
        /// If you don't have one, create a standalone app here: https://vk.com/editapp?act=create </param>
        public static void Initialize(String appId)
        {
            Logger = new DefaultLogger();

            if (String.IsNullOrEmpty(appId))
            {
                throw new Exception("VKSDK could not initialize. " +
                                    "Application ID cannot be null or empty. " +
                                    "If you don't have one, create a standalone app here: https://vk.com/editapp?act=create");
            }

            if (Instance == null)
            {
                Instance = new VKSDK();
            }



            Instance.CurrentAppID = appId;
        }
        public static bool HandleUri(Uri uri)
        {
            var tempUriStr = uri.ToString();

            if (tempUriStr.StartsWith("/Protocol"))
            {
                var outerQueryParamsString = VKUtil.GetParamsOfQueryString(tempUriStr);

                if (!string.IsNullOrEmpty(outerQueryParamsString))
                {
                    var outerQueryParams = VKUtil.ExplodeQueryString(outerQueryParamsString);
                    if (outerQueryParams.ContainsKey("encodedLaunchUri"))
                    {
                        var launchUriEncoded = outerQueryParams["encodedLaunchUri"];

                        var launchUriDecoded = WebUtility.UrlDecode(launchUriEncoded);

                        if (launchUriDecoded.StartsWith("vk") && launchUriDecoded.Contains("://authorize"))
                        {
                            launchUriDecoded = launchUriDecoded.Replace("authorize/#", "authorize/?");

                            var innerQueryParamsString = VKUtil.GetParamsOfQueryString(launchUriDecoded);

                            VKSDK.ProcessLoginResult(innerQueryParamsString, false, null);

                            return(true);
                        }
                        else
                        {
                            // default start
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }