Esempio n. 1
0
        /// <summary>
        /// Handles an <c>onGetFeedFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// json array of feeds</param>
        public void onGetFeedFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetFeedFinished");

            JSONObject    eventJson = new JSONObject(message);
            Provider      provider  = Provider.fromInt((int)eventJson["provider"].n);
            JSONObject    feedsJson = eventJson ["feeds"];
            List <String> feeds     = new List <String>();

            foreach (JSONObject feedVal in feedsJson.list)
            {
                //iterate "feed" keys
                feeds.Add(feedVal.str);
            }

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

            //JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);
            SocialPageData <String> result = new SocialPageData <String>();

            result.PageData   = feeds;
            result.PageNumber = 0;
            result.HasMore    = hasMore;
            ProfileEvents.OnGetFeedFinished(provider, result);
        }
        /// <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);
                });
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Handles an <c>onGetFeedFinished</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// json array of feeds</param>
        public void onGetFeedFinished(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetFeedFinished");

            JSONObject eventJson = new JSONObject(message);

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

            JSONObject    feedsJson = eventJson ["feeds"];
            List <String> feeds     = new List <String>();

            foreach (String key in feedsJson.keys)
            {
                //iterate "feed" keys
                feeds.Add(feedsJson[key].str);
            }

            ProfileEvents.OnGetFeedFinished(provider, feeds);
        }