public void ShowAppInviteDialogRequest(Dictionary <string, object> parameters)
        {
            var appLinkUrl      = $"{parameters["appLinkUrl"]}";
            var previewImageUrl = $"{parameters["previewImageUrl"]}";
            var promotionCode   = $"{parameters["promotionCode"]}";
            var promotionText   = $"{parameters["promotionText"]}";
            var destination     = FacebookAppInviteDestination.Facebook;

            if (parameters["destination"] is FacebookAppInviteDestination)
            {
                destination = (FacebookAppInviteDestination)parameters["destination"];
            }

            if (AppInviteDialog.CanShow() && !string.IsNullOrEmpty(appLinkUrl))
            {
                AppInviteContent.Builder appInviteContentBuilder = new AppInviteContent.Builder();

                appInviteContentBuilder.SetApplinkUrl(appLinkUrl);

                appInviteContentBuilder.SetDestination(destination == FacebookAppInviteDestination.Facebook?AppInviteContent.Builder.Destination.Facebook: AppInviteContent.Builder.Destination.Messenger);

                if (!string.IsNullOrEmpty(previewImageUrl))
                {
                    appInviteContentBuilder.SetPreviewImageUrl(previewImageUrl);
                }

                if (!string.IsNullOrEmpty(promotionText) || !string.IsNullOrEmpty(promotionCode))
                {
                    appInviteContentBuilder.SetPromotionDetails(promotionText, promotionCode);
                }
                AppInviteDialog AppInv = new AppInviteDialog(CurrentActivity);
                AppInv.RegisterCallback(mCallbackManager, appInviteCallback);
                AppInv.Show(appInviteContentBuilder.Build().JavaCast <AppInviteContent>());
            }
        }
Exemplo n.º 2
0
        public void ShowAppInviteDialogRequest(Dictionary <string, object> parameters)
        {
            var appLinkUrl      = $"{parameters["appLinkUrl"]}";
            var previewImageUrl = $"{parameters["previewImageUrl"]}";
            var promotionCode   = $"{parameters["promotionCode"]}";
            var promotionText   = $"{parameters["promotionText"]}";
            var destination     = FacebookAppInviteDestination.Facebook;

            if (parameters["destination"] is FacebookAppInviteDestination)
            {
                destination = (FacebookAppInviteDestination)parameters["destination"];
            }

            if (!string.IsNullOrEmpty(appLinkUrl))
            {
                AppInviteContent content = new AppInviteContent()
                {
                    AppLinkURL = NSUrl.FromString(appLinkUrl)
                };

                if (!string.IsNullOrEmpty(previewImageUrl))
                {
                    content.PreviewImageURL = NSUrl.FromString(previewImageUrl);
                }

                content.Destination = destination == FacebookAppInviteDestination.Facebook ? AppInviteDestination.Facebook : AppInviteDestination.Messenger;

                if (!string.IsNullOrEmpty(promotionText))
                {
                    content.PromotionText = promotionText;
                }

                if (!string.IsNullOrEmpty(promotionCode))
                {
                    content.PromotionCode = promotionCode;
                }

                UIApplication.SharedApplication.InvokeOnMainThread(() =>
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var vc     = window.RootViewController;
                    while (vc.PresentedViewController != null)
                    {
                        vc = vc.PresentedViewController;
                    }
                    AppInviteDialog.Show(vc, content, this);
                });
            }
        }