Exemplo n.º 1
0
        /// <summary>
        /// Handles an <c>onInviteCancelled</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// numeric representation of <c>SocialActionType</c> and payload</param>
        public void onInviteCancelled(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onInviteCancelled");

            JSONObject eventJson = new JSONObject(message);

            Provider provider = Provider.fromInt((int)eventJson["provider"].n);

            JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

            ProfileEvents.OnInviteCancelled(provider, ProfilePayload.GetUserPayload(payloadJSON));
        }
Exemplo n.º 2
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);
                });
            }
        }