Example #1
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);
                });
            }
        }
		// Invite user's friends to use your Facebook app
		void InviteFriends ()
		{
			var content = new AppInviteContent (appLinkUrl);
			content.PreviewImageURL = previewImageUrl;
			AppInviteDialog.Show (content, this);
		}