Ejemplo n.º 1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            FindViewById <Button>(Resource.Id.create).Click     += CreateAppLinkAsync;
            FindViewById <Button>(Resource.Id.shareShort).Click += ShareShortAppLink_Click;

            try
            {
                // To receive links, initialize the AGConnectAppLinking instance.
                AGConnectAppLinking appLinkInstance = AGConnectAppLinking.Instance;

                // Call GetAppLinkingAsync to check for links of App Linking to be processed.
                ResolvedLinkData resolvedLinkData = await appLinkInstance.GetAppLinkingAsync(this);

                // Get App Linking data.
                Uri deepLink = resolvedLinkData.DeepLink;

                FindViewById <TextView>(Resource.Id.linking_info).Text = "get Linking success, the deepLink: " + deepLink.ToString();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex.ToString());
            }
        }
 public void GetResulveData()
 {
     AGConnectAppLinking.getInstance().getAppLinking(new UnityPlayerActivity()).addOnSuccessListener(new HmsSuccessListener <ResolvedLinkData>((resolvedLinkData) =>
     {
         var link = resolvedLinkData.getDeepLink().toString();
         TestTip.Inst.ShowText("short link:" + link);
         GUIUtility.systemCopyBuffer = link;
         var time = resolvedLinkData.getClickTimestamp();
         TestTip.Inst.ShowText("Time stamp:" + time);
         var socialTitle = resolvedLinkData.getSocialTitle();
         TestTip.Inst.ShowText("socialTitle: " + socialTitle);
         var socialImageUrl = resolvedLinkData.getSocialImageUrl();
         TestTip.Inst.ShowText("socialImageUrl: " + socialImageUrl);
         var socialDescription = resolvedLinkData.getSocialDescription();
         TestTip.Inst.ShowText("socialDescription: " + socialDescription);
         var campaignName = resolvedLinkData.getCampaignName();
         TestTip.Inst.ShowText("campaignName: " + campaignName);
         var campaignMedium = resolvedLinkData.getCampaignMedium();
         TestTip.Inst.ShowText("campaignMedium: " + campaignMedium);
         var campaignSource = resolvedLinkData.getCampaignSource();
         TestTip.Inst.ShowText("campaignSource: " + campaignSource);
     })).addOnFailureListener(new HmsFailureListener((Exception e) => {
         TestTip.Inst.ShowText($"short link failed: {e.toString()}");
     }));
 }
Ejemplo n.º 3
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_detail);


            try
            {
                //To receive links, initialize the AGConnectAppLinking instance.
                AGConnectAppLinking appLinkInstance = AGConnectAppLinking.Instance;

                //Before receiving a link of App Linking for the first time, set a custom referrer
                appLinkInstance.SetCustomReferrer(new CustomReferrerProvider());


                //Call GetAppLinkingAsync() to check for links of App Linking to be processed
                ResolvedLinkData resolvedLinkData = await appLinkInstance.GetAppLinkingAsync(this);

                string message  = "";
                string campaign = "";
                string social   = "";
                Uri    deepLink = null;
                if (resolvedLinkData != null)
                {
                    message = $"AppLink: {resolvedLinkData.DeepLink?.ToString()}\nTime: {resolvedLinkData.ClickTimestamp.UnixTimeStampToDateTime()}\nMin App Version: {resolvedLinkData.MinimumAppVersion}";

                    campaign = $"Campaign Name:{resolvedLinkData.CampaignName} \n Campaign Medium:{resolvedLinkData.CampaignMedium} \n Campaign Source:{resolvedLinkData.CampaignSource}";

                    social = $"Social Title:{resolvedLinkData.SocialTitle} \n Social Description:{resolvedLinkData.SocialDescription} \n Social Image URL:{resolvedLinkData.SocialImageUrl}";

                    FindViewById <TextView>(Resource.Id.txtAppLink).Text      = message;
                    FindViewById <TextView>(Resource.Id.txtCampaignInfo).Text = campaign;
                    FindViewById <TextView>(Resource.Id.txtSocialInfo).Text   = social;
                }

                //Get detail applink
                if (Intent != null)
                {
                    deepLink = resolvedLinkData.DeepLink;
                    if (deepLink != null)
                    {
                        string path = deepLink.LastPathSegment;
                        if (path == "detail")
                        {
                            string detail = "";
                            foreach (var item in deepLink.QueryParameterNames)
                            {
                                detail += deepLink.GetQueryParameter(item);
                            }

                            FindViewById <TextView>(Resource.Id.txtDetailLink).Text = "id = " + detail;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                FindViewById <TextView>(Resource.Id.txtAppLink).Text = ex.Message;
            }
        }