/// <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);
                });
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles an <c>onGetFeedFailed</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>,
        /// and an error message</param>
        public void onGetFeedFailed(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetFeedFailed");

            JSONObject eventJson = new JSONObject(message);

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

            ProfileEvents.OnGetFeedFailed(provider, errorMessage);
        }