Esempio n. 1
0
        private void AddSocialInfo_Click(object sender, EventArgs e)
        {
            // Set Sharing Identifier (Optional)
            // Your links appears with title, description and image url on Facebook, Twitter etc.
            SocialCardInfo.Builder socialCard = new AppLinking.SocialCardInfo.Builder();
            socialCard.SetImageUrl("IMAGE_URL");
            socialCard.SetDescription("AppLink Share Description");
            socialCard.SetTitle("AppLink Share Title");
            builder.SetSocialCardInfo(socialCard.Build());

            FindViewById <TextView>(Resource.Id.txtLink).Text = builder.BuildAppLinking().Uri.ToString();
        }
Esempio n. 2
0
        public void CreateAppLink()
        {
            builder = new AppLinking.Builder();
            // Set URL Prefix
            builder.SetUriPrefix(Utility.UriPrefix);
            // Set Deep Link
            builder.SetDeepLink(Uri.Parse(Utility.OpenApp_Link));

            //Set the link preview type. If this method is not called, the preview page with app information is displayed by default.
            builder.SetPreviewType(AppLinking.LinkingPreviewType.AppInfo);

            // Set Android link behavior (Optional)
            var behaviorBuilder = new AppLinking.AndroidLinkInfo.Builder();

            // Set Min Version if user app's version less than version number or users direct to AppGallery
            behaviorBuilder.SetMinimumVersion(1);
            builder.SetAndroidLinkInfo(behaviorBuilder.Build());

            FindViewById <TextView>(Resource.Id.txtLink).Text = builder.BuildAppLinking().Uri.ToString();
        }
Esempio n. 3
0
        private async void CreateAppLinkAsync(object sender, EventArgs e)
        {
            string UriPrefix        = "<your_AppLinking_URL_Prefix>";
            string OpenDeep_Link    = "https://developer.huawei.com";
            string AndroidDeep_Link = "androidlink://developer.huawei.com/consumer/cn";

            AppLinking.Builder builder = new AppLinking.Builder();

            // Set URL Prefix
            builder.SetUriPrefix(UriPrefix);
            // Set Deep Link
            builder.SetDeepLink(Uri.Parse(OpenDeep_Link));

            //Set the link preview type. If this method is not called, the preview page with app information is displayed by default.
            builder.SetPreviewType(AppLinking.LinkingPreviewType.AppInfo);

            // Set Android link behavior (Optional)
            // If this parameters not set, the link will be opened in the Android browser by default.
            var androidLinkInfo = new AppLinking.AndroidLinkInfo.Builder();

            androidLinkInfo.SetAndroidDeepLink(AndroidDeep_Link);
            androidLinkInfo.SetOpenType(AppLinking.AndroidLinkInfo.AndroidOpenType.AppGallery);
            builder.SetAndroidLinkInfo(androidLinkInfo.Build());

            // obtain the long link.
            FindViewById <TextView>(Resource.Id.longLinkText).Text = builder.BuildAppLinking().Uri.ToString();
            // obtain the short link.
            try
            {
                ShortAppLinking link = await builder.BuildAppShortLinkingAsync(ShortAppLinking.LENGTH.Short);

                FindViewById <TextView>(Resource.Id.shortLinkText).Text = link.ShortUrl.ToString();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex.ToString());
            }
        }