예제 #1
0
        /// <summary>
        /// Updates the user's status on the given provider.
        /// Supported platforms: Facebook, Twitter, Google+
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> the given status should be posted to.</param>
        /// <param name="status">The actual status text.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        /// <param name="reward">A <c>Reward</c> to give the user after a successful post.</param>
        public static void UpdateStatus(Provider provider, string status, 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 : "";
                instance._updateStatus(provider, status, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
            }

            else
            {
                ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPDATE_STATUS, userPayload);
                targetProvider.UpdateStatus(status,
                                            /* success */ () => {
                    ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPDATE_STATUS, userPayload);
                    if (reward != null)
                    {
                        reward.Give();
                    }
                },
                                            /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPDATE_STATUS, error, userPayload); }
                                            );
            }
        }
예제 #2
0
        /// <summary>
        /// Fetches UserProfiles of contacts of the current user.
        /// Supported platforms: Facebook, Twitter, Google+.
        /// Missing contact information for Twitter: email, gender, birthday.
        /// Missing contact information for Google+: username, email, gender, bithday
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> to fetch contacts from.</param>
        /// <param name="pageNumber">The contacts' page number to get.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        public static void GetContacts(Provider provider, int pageNumber = 0, string payload = "")
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                //TODO: add pageNumber here when implemented natively
                instance._getContacts(provider, ProfilePayload.ToJSONObj(userPayload).ToString());
            }

            else
            {
                ProfileEvents.OnGetContactsStarted(provider, pageNumber, userPayload);
                targetProvider.GetContacts(pageNumber,
                                           /* success */ (SocialPageData <UserProfile> contactsData) => {
                    ProfileEvents.OnGetContactsFinished(provider, contactsData, userPayload);
                },
                                           /* fail */ (string message) => { ProfileEvents.OnGetContactsFailed(provider, pageNumber, message, userPayload); }
                                           );
            }
        }
예제 #3
0
        // <summary>
        // Uploads an image to the user's social page on the given Provider.
        // Supported platforms: Facebook
        //
        // NOTE: This operation requires a successful login.
        // </summary>
        // <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param>
        // <param name="message">Message to post with the image.</param>
        // <param name="filePath">Path of image file.</param>
        // <param name="payload">A string to receive when the function returns.</param>
        // <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param>
        public static void UploadImage(Provider provider, string message, string filePath, 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 : "";
                instance._uploadImage(provider, message, filePath, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
            }

            else
            {
                Texture2D tex2D = new Texture2D(4, 4);
                tex2D.LoadImage(File.ReadAllBytes(filePath));
                string fileName = Path.GetFileName(filePath);

                UploadImage(provider, tex2D, fileName, message, userPayload, reward);
            }
        }
예제 #4
0
        /// <summary>
        /// Uploads an image to the user's social page on the given Provider with confirmation dialog.
        /// Supported platforms: Facebook, Twitter, Google+
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param>
        /// <param name="message">Message to post with the image.</param>
        /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param>
        /// <param name="imageBytes">Image bytes.</param>
        /// <param name="jpegQuality">Image quality, number from 0 to 100. 0 meaning compress for small size, 100 meaning compress for max quality.
        /// Some formats, like PNG which is lossless, will ignore the quality setting
        /// <param name="payload">A string to receive when the function returns.</param>
        /// <param name="reward">A <c>Reward</c> to give the user after a successful upload.</param>
        /// <param name="customMessage">The message to show in the dialog</param>
        public static void UploadImageWithConfirmation(Provider provider, string message, string fileName, byte[] imageBytes,
                                                       int jpegQuality, string payload = "", Reward reward = null, string customMessage = null)
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                string rewardId = reward != null ? reward.ID: "";
                instance._uploadImage(provider, message, fileName, imageBytes, jpegQuality,
                                      ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), true, customMessage);
            }

            else
            {
                // TODO: Support showConfirmation
                ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPLOAD_IMAGE, userPayload);
                targetProvider.UploadImage(imageBytes, fileName, message,
                                           /* success */ () => {
                    if (reward != null)
                    {
                        reward.Give();
                    }
                    ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPLOAD_IMAGE, userPayload);
                },
                                           /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPLOAD_IMAGE, error, userPayload); },
                                           /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPLOAD_IMAGE, userPayload); }
                                           );
            }
        }
        /// <summary>
        /// Retrieves a list of the user's feed entries from the supplied provider.
        /// Upon a successful retrieval of feed entries the user will be granted the supplied reward.
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> on which to retrieve a list of feed entries.</param>
        /// <param name="fromStart">Should we reset pagination or request the next page.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        /// <param name="reward">The reward which will be granted to the user upon a successful retrieval of feed.</param>
        public static void GetFeed(Provider provider, bool fromStart = false, string payload = "", Reward reward = null)
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                string rewardId = reward != null ? reward.ID: "";
                //fallback to native
                instance._getFeed(provider, fromStart, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
            }
            else
            {
                ProfileEvents.OnGetFeedStarted(provider);
                targetProvider.GetFeed(fromStart,
                                       /* success */
                                       (SocialPageData <String> feeds) => {
                    if (reward != null)
                    {
                        reward.Give();
                    }
                    ProfileEvents.OnGetFeedFinished(provider, feeds);
                },
                                       /* fail */
                                       (string message) => {
                    ProfileEvents.OnGetFeedFailed(provider, message);
                });
            }
        }
예제 #6
0
        /// <summary>
        /// Handles an <c>onInviteFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// numeric representation of <c>SocialActionType</c>
        /// id of given request, list of invite recipients
        /// and payload</param>
        public void onInviteFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onInviteFinished");

            JSONObject eventJson = new JSONObject(message);

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

            String        requestId      = eventJson["requestId"].str;
            JSONObject    recipientsJson = eventJson ["invitedIds"];
            List <String> recipients     = new List <String>();

            foreach (JSONObject recipientVal in recipientsJson.list)
            {
                //iterate "feed" keys
                recipients.Add(recipientVal.str);
            }

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

            //give a reward
            Reward reward = Reward.GetReward(ProfilePayload.GetRewardId(payloadJSON));

            if (reward != null)
            {
                reward.Give();
            }

            ProfileEvents.OnInviteFinished(provider, requestId, recipients, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #7
0
        /// <summary>
        /// Fetches UserProfiles of contacts of the current user.
        /// Supported platforms: Facebook, Twitter, Google+.
        /// Missing contact information for Twitter: email, gender, birthday.
        /// Missing contact information for Google+: username, email, gender, bithday
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> to fetch contacts from.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        public static void GetContacts(Provider provider, string payload = "")
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                instance._getContacts(provider, ProfilePayload.ToJSONObj(userPayload).ToString());
            }

            else
            {
                ProfileEvents.OnGetContactsStarted(provider, userPayload);
                targetProvider.GetContacts(
                    /* success */ (List <UserProfile> profiles) => {
                    ProfileEvents.OnGetContactsFinished(provider, profiles, userPayload);
                },
                    /* fail */ (string message) => { ProfileEvents.OnGetContactsFailed(provider, message, userPayload); }
                    );
            }
        }
예제 #8
0
        /// <summary>
        /// Handles an <c>onGetContactsFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// JSON array of <c>UserProfile</c>s and payload</param>
        public void onGetContactsFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetContactsFinished");

            JSONObject eventJson = new JSONObject(message);

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

            bool hasMore = eventJson["hasMore"].b;

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

            JSONObject         userProfilesArray = eventJson ["contacts"];
            List <UserProfile> userProfiles      = new List <UserProfile>();

            foreach (JSONObject userProfileJson in userProfilesArray.list)
            {
                userProfiles.Add(new UserProfile(userProfileJson));
            }

            SocialPageData <UserProfile> data = new SocialPageData <UserProfile>();

            data.PageData   = userProfiles;
            data.PageNumber = 0;
            data.HasMore    = hasMore;

            ProfileEvents.OnGetContactsFinished(provider, data, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #9
0
        /// <summary>
        /// Handles an <c>onShowLeaderboards</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// </param>
        public void onShowLeaderboards(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onShowLeaderboards");

            JSONObject eventJson = new JSONObject(message);

            Provider   provider    = Provider.fromInt((int)eventJson["provider"].n);
            JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

            ProfileEvents.OnShowLeaderboards(new ShowLeaderboardsEvent(provider, ProfilePayload.GetUserPayload(payloadJSON)));
        }
예제 #10
0
        /// <summary>
        /// Handles an <c>onLoginStarted</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// as well as payload </param>
        public void onLoginStarted(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLoginStarted");

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

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

            ProfileEvents.OnLoginStarted(provider, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #11
0
        /// <summary>
        /// Handles an <c>onInviteFailed</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// numeric representation of <c>SocialActionType</c>,
        /// error message and payload</param>
        public void onInviteFailed(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onInviteFailed");

            JSONObject eventJson = new JSONObject(message);

            Provider provider     = Provider.fromInt((int)eventJson["provider"].n);
            String   errorMessage = eventJson["message"].str;

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

            ProfileEvents.OnInviteFailed(provider, errorMessage, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #12
0
        /// <summary>
        /// Handles an <c>onSocialActionCancelled</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 onSocialActionCancelled(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSocialActionCancelled");

            JSONObject eventJson = new JSONObject(message);

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

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

            ProfileEvents.OnSocialActionCancelled(provider, socialAction, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #13
0
        /// <summary>
        /// Handles an <c>onGetContactsStarted</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// and payload</param>
        public void onGetContactsStarted(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetContactsStarted");

            JSONObject eventJson = new JSONObject(message);

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

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

            bool fromStart = eventJson["fromStart"].b;

            ProfileEvents.OnGetContactsStarted(provider, fromStart, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #14
0
        /// <summary>
        /// Handles an <c>onLoginCancelled</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// as well as payload </param>
        public void onLoginCancelled(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLoginCancelled");

            JSONObject eventJson = new JSONObject(message);

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

            bool autoLogin = eventJson["autoLogin"].b;

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

            ProfileEvents.OnLoginCancelled(provider, autoLogin, ProfilePayload.GetUserPayload(payloadJSON));
            //ProfileEvents.OnLoginCancelled (new LoginCancelledEvent(provider, autoLogin, ProfilePayload.GetUserPayload(payloadJSON)));
        }
예제 #15
0
        /// <summary>
        /// Logs the user into the given provider.
        /// Supported platforms: Facebook, Twitter, Google+
        /// </summary>
        /// <param name="provider">The provider to log in to.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        /// <param name="reward">A <c>Reward</c> to give the user after a successful login.</param>
        public static void Login(Provider provider, string payload = "", Reward reward = null)
        {
            SoomlaUtils.LogDebug(TAG, "Trying to login with provider " + provider.ToString());
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                SoomlaUtils.LogError(TAG, "Provider not supported or not set as active: " + provider.ToString());
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                string rewardId = reward != null ? reward.ID : "";
                instance._login(provider, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
            }

            else
            {
                setLoggedInForProvider(provider, false);
                ProfileEvents.OnLoginStarted(provider, userPayload);
                targetProvider.Login(
                    /* success */ () => {
                    targetProvider.GetUserProfile((UserProfile userProfile) => {
                        StoreUserProfile(userProfile);
                        setLoggedInForProvider(provider, true);
                        ProfileEvents.OnLoginFinished(userProfile, userPayload);
                        if (reward != null)
                        {
                            reward.Give();
                        }
                    }, (string message) => {
                        ProfileEvents.OnLoginFailed(provider, message, userPayload);
                    });
                },
                    /* fail */ (string message) => { ProfileEvents.OnLoginFailed(provider, message, userPayload); },
                    /* cancel */ () => { ProfileEvents.OnLoginCancelled(provider, userPayload); }
                    );
            }
        }
예제 #16
0
        /// <summary>
        /// Handles an <c>onGetContactsFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// JSON array of <c>UserProfile</c>s and payload</param>
        public void onGetContactsFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetContactsFinished");

            JSONObject eventJson = new JSONObject(message);

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

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

            JSONObject         userProfilesArray = eventJson ["contacts"];
            List <UserProfile> userProfiles      = new List <UserProfile>();

            foreach (JSONObject userProfileJson in userProfilesArray.list)
            {
                userProfiles.Add(new UserProfile(userProfileJson));
            }

            ProfileEvents.OnGetContactsFinished(provider, userProfiles, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #17
0
        /// <summary>
        /// Handles an <c>onLoginFinished</c> event
        /// </summary>
        /// <param name="message">Will contain a JSON representation of a <c>UserProfile</c> and payload</param>
        public void onLoginFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLoginFinished");

            JSONObject eventJson = new JSONObject(message);

            UserProfile userProfile = new UserProfile(eventJson ["userProfile"]);

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

            //give a reward
            Reward reward = Reward.GetReward(ProfilePayload.GetRewardId(payloadJSON));

            if (reward != null)
            {
                reward.Give();
            }

            ProfileEvents.OnLoginFinished(userProfile, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #18
0
        /// <summary>
        /// Handles an <c>onSocialActionFinished</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 onSocialActionFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSocialActionFinished");

            JSONObject eventJson = new JSONObject(message);

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

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

            //give a reward
            Reward reward = Reward.GetReward(ProfilePayload.GetRewardId(payloadJSON));

            if (reward != null)
            {
                reward.Give();
            }

            ProfileEvents.OnSocialActionFinished(provider, socialAction, ProfilePayload.GetUserPayload(payloadJSON));
        }
예제 #19
0
        /// <summary>
        /// Posts a full story to the user's social page on the given Provider with confirmation dialog.
        /// A story contains a title, description, image and more.
        /// Supported platforms: Facebook (full support),
        /// Twitter and Google+ (partial support - message and link only)
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> the given story should be posted to.</param>
        /// <param name="message">A message that will be shown along with the story.</param>
        /// <param name="name">The name (title) of the story.</param>
        /// <param name="caption">A caption.</param>
        /// <param name="description">A description.</param>
        /// <param name="link">A link to a web page.</param>
        /// <param name="pictureUrl">A link to an image on the web.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        /// <param name="reward">A <c>Reward</c> to give the user after a successful post.</param>
        /// <param name="customMessage">The message to show in the dialog</param>
        public static void UpdateStoryWithConfirmation(Provider provider, string message, string name,
                                                       string caption, string description, string link, string pictureUrl,
                                                       string payload       = "", Reward reward = null,
                                                       string customMessage = 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: "";
                instance._updateStory(provider, message, name, caption, description, link, pictureUrl,
                                      ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), true, customMessage);
            }

            else
            {
                // TODO: Support showConfirmation
                ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPDATE_STORY, userPayload);
                targetProvider.UpdateStory(message, name, caption, link, pictureUrl,
                                           /* success */ () => {
                    if (reward != null)
                    {
                        reward.Give();
                    }
                    ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPDATE_STORY, userPayload);
                },
                                           /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPDATE_STORY, error, userPayload); },
                                           /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPDATE_STORY, userPayload); }
                                           );
            }
        }
예제 #20
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);
                });
            }
        }
예제 #21
0
        /// <summary>
        /// Handles an <c>onReportScoreFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// and payload</param>
        public void onReportScoreFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onReportScoreFinished");

            JSONObject eventJson = new JSONObject(message);

            Provider    provider = Provider.fromInt((int)eventJson["provider"].n);
            Leaderboard owner    = new Leaderboard(eventJson["leaderboard"]);
            Score       score    = new Score(eventJson["score"]);

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

            ProfileEvents.OnReportScoreFinished(new ReportScoreFinishedEvent(provider, owner, score, ProfilePayload.GetUserPayload(payloadJSON)));
        }
예제 #22
0
        /// <summary>
        /// Handles an <c>onGetLeaderboardsFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// and payload</param>
        public void onGetLeaderboardsFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetLeaderboardsFinished");

            JSONObject eventJson = new JSONObject(message);

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


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

            JSONObject         leaderboardsArray = eventJson ["leaderboards"];
            List <Leaderboard> leaderboards      = new List <Leaderboard>();

            foreach (JSONObject leaderboardJson in leaderboardsArray.list)
            {
                leaderboards.Add(new Leaderboard(leaderboardJson));
            }

            SocialPageData <Leaderboard> data = new SocialPageData <Leaderboard>();

            data.PageData   = leaderboards;
            data.PageNumber = 0;
            data.HasMore    = false;

            ProfileEvents.OnGetLeaderboardsFinished(new GetLeaderboardsFinishedEvent(provider, data, ProfilePayload.GetUserPayload(payloadJSON)));
        }
예제 #23
0
        /// <summary>
        /// Handles an <c>onGetScoresFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// and payload</param>
        public void onGetScoresFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetScoresFinished");

            JSONObject eventJson = new JSONObject(message);

            Provider    provider = Provider.fromInt((int)eventJson["provider"].n);
            Leaderboard owner    = new Leaderboard(eventJson["leaderboard"]);

            bool hasMore = eventJson["hasMore"].b;

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

            JSONObject   scoresArray = eventJson ["scores"];
            List <Score> scores      = new List <Score>();

            foreach (JSONObject scoreJson in scoresArray.list)
            {
                scores.Add(new Score(scoreJson));
            }

            SocialPageData <Score> data = new SocialPageData <Score>();

            data.PageData   = scores;
            data.PageNumber = 0;
            data.HasMore    = hasMore;

            ProfileEvents.OnGetScoresFinished(new GetScoresFinishedEvent(provider, owner, data, ProfilePayload.GetUserPayload(payloadJSON)));
        }
예제 #24
0
        /// <summary>
        /// Handles an <c>onSubmitScoreFailed</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// and payload</param>
        public void onSubmitScoreFailed(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSubmitScoreFailed");

            JSONObject eventJson = new JSONObject(message);

            Provider    provider     = Provider.fromInt((int)eventJson["provider"].n);
            Leaderboard owner        = new Leaderboard(eventJson["leaderboard"]);
            String      errorMessage = eventJson["message"].str;

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

            ProfileEvents.OnSubmitScoreFailed(new SubmitScoreFailedEvent(provider, owner, errorMessage, ProfilePayload.GetUserPayload(payloadJSON)));
        }