Пример #1
0
        public static void Invite(Provider provider, string inviteMessage, string dialogTitle = null, string payload = "", Reward reward = null)
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                string rewardId = reward != null ? reward.ID: "";
                //TODO: add invite implementation when implemented in native
                instance._invite(provider, inviteMessage, dialogTitle, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
            }

            else
            {
                ProfileEvents.OnInviteStarted(provider, userPayload);
                targetProvider.Invite(inviteMessage, dialogTitle,
                                      /* success */ (string requestId, List <string> invitedIds) => {
                    if (reward != null)
                    {
                        reward.Give();
                    }
                    ProfileEvents.OnInviteFinished(provider, requestId, invitedIds, userPayload);
                },
                                      /* fail */ (string message) => {
                    ProfileEvents.OnInviteFailed(provider, message, userPayload);
                },
                                      /* cancel */ () => {
                    ProfileEvents.OnInviteCancelled(provider, userPayload);
                });
            }
        }