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

            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.OnGetContactsFailed(provider, 0, errorMessage, ProfilePayload.GetUserPayload(payloadJSON));
        }