Mesibo Profile Listeners
Estimated reading time: 2 minutesThere are two types of profile listeners in the mesibo Profile API:
- Mesibo.ProfileListener The global listener interface, for all subscribed profiles
- MesiboProfile.Listener Per profile listener.
Global Profile Listener - Mesibo.ProfileListener
Your app can implement the Mesibo.ProfileListener
to be notified of global profile events - either when a profile that you have subscribed to has been updated on the server, or a profile is being accessed.
The following global listeners are a part of Mesibo.ProfileListener
:
Mesibo_onProfileUpdated
Mesibo_onProfileUpdated
is called when a profile that you have subscribed to is updated globally.
void Mesibo_onProfileUpdated(MesiboProfile profile){
// Updated profile object recieved
}
Mesibo_onGetProfile
Mesibo_onGetProfile
is called whenever your app accesses a profile. You can make modifications to the profile object here as per your local context. For example, if you are syncing profiles of contacts on your phone, you may change the name on a user’s profile as per your local address book. Note that this listener will only be called for the first time you access a profile.
If the app makes modifications to the original profile make the listener return true. If no modifications were made return false.
boolean Mesibo_onGetProfile(MesiboProfile profile){
// This profile was accessed
// Make modifications to the profile
return true;
}
Once you implement Mesibo.ProfileListener
, add that as a listener as follows:
Mesibo.addListener(this);
Per Profile Listener - MesiboProfile.Listener
There are situations where you need to set a listener for particular profiles only. For example, in a messaging app, say you have expanded a profile. For now, you are only concerned about being notified of updates for a selected profile. So, set the listener only for selected profile.
To set a listener for each profile, implement MesiboProfile.Listener
and set it.
The following listener is available in MesiboProfile.Listener
:
- MesiboProfile_onUpdate Called when the owner of this profile updates their profile.
void MesiboProfile_onUpdate(MesiboProfile profile){
// This profile has been updated
}
Once you implement a MesiboProfile.Listener
, set the listener for that profile as follows:
profile.addListener(mProfileSelected);
// mProfileSelected implements `MesiboProfile.Listener`