示例#1
0
        // NOTE: You must have the App Store ID set in your developer console project
        // in order for invitations to successfully be sent.
        public void SendInvite()
        {
            if (string.IsNullOrWhiteSpace(txtTitle.Value) ||
                string.IsNullOrWhiteSpace(txtMessage.Text))
            {
                AppDelegate.ShowMessage("You are missing some information…", "Please, fill all fields marked with *.", ParentViewController);
                return;
            }

            if (txtMessage.Text.Length > 100 || txtDescription.Text.Length > 1000)
            {
                AppDelegate.ShowMessage("Length exceeded!", "Too much characters to be sent through Invtes.", ParentViewController);
                return;
            }

            // When you create the invitation dialog, you must specify the title
            // of the invitation dialog and the invitation message to send.
            // You can also customize the image and deep link URL that
            // get sent in the invitation
            var inviteDialog = Invites.GetInviteDialog();

            inviteDialog.SetInviteDelegate(this);
            inviteDialog.SetTitle(txtTitle.Value);
            inviteDialog.SetMessage(txtMessage.Text);

            if (!string.IsNullOrWhiteSpace(txtDeepLink.Value))
            {
                inviteDialog.SetDeepLink(txtDeepLink.Value);
            }

            if (!string.IsNullOrWhiteSpace(txtDescription.Text))
            {
                inviteDialog.SetDescription(txtDescription.Text);
            }

            if (!string.IsNullOrWhiteSpace(txtCustomImage.Value))
            {
                inviteDialog.SetCustomImage(txtCustomImage.Value);
            }

            if (!string.IsNullOrWhiteSpace(txtCallToAction.Value))
            {
                inviteDialog.SetCallToActionText(txtCallToAction.Value);
            }


            // If you have an Android version of your app and you want to send
            // an invitation that can be opened on Android in addition to iOS
            if (!string.IsNullOrWhiteSpace(txtAndroidId.Value))
            {
                var targetApp = new InvitesTargetApplication {
                    AndroidClientId = txtAndroidId.Value
                };
                inviteDialog.SetOtherPlatformsTargetApplication(targetApp);
            }

            inviteDialog.Open();
        }