/// <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); } ); } }
/// <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); } ); } }
/// <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); ProfileEvents.OnGetContactsStarted(provider, 0, ProfilePayload.GetUserPayload(payloadJSON)); }