Getting Started Guide
Creating Groups
Group messaging is no different from the one-to-one messaging. You can invoke the same messaging APIs to send a group message, instead of the user's profile, you need to use group profile.
mesibo allows you to create various types of groups, with different level of permissions for members and admins. You can learn more about it in Group Management APIs documentation.
In this section, we will quickly learn to create a group.
Creating a Group
To create a group and add members, you need to use the Group Management APIs. This is the recommended approach. However, you can also create a group and add/remove members by using backend APIs and mesibo console if requires.
You can create a new group by calling createGroup
API, with name and the Group Listener Object. It will send a request to the server to create a new group. When a group is created, callback function in the listener will be called with the group profile. You can then add members to the group using group profile APIs.
Refer to the Group Management APIs for more details on GroupSettings and listener:
To create a group:
MesiboGroupProfile.GroupSettings settings = new MesiboGroupProfile.GroupSettings();
settings.name = "My Group";
settings.flags = 0;
Mesibo.createGroup(settings, this);
If the creation of a group is successful, the Mesibo_onGroupCreated
listener function will be called with group profile.
@Override
public void Mesibo_onGroupCreated(MesiboProfile profile) {
Log.d(TAG, "New group " + groupProfile.groupid);
}
To create a group:
val settings = GroupSettings()
settings.name = "My Group"
settings.flags = 0
Mesibo.createGroup(settings, this)
If the creation of a group is successful, the Mesibo_onGroupCreated
listener function will be called with group profile.
override fun Mesibo_onGroupCreated(profile: MesiboProfile) {
toast("New Group Created: " + profile.name)
}
To create a group:
let gs:MesiboGroupSettings = MesiboGroupSettings();
gs.name = "My First Group";
gs.flags = 0;
Mesibo.getInstance().createGroup(gs, listener: self)
If the creation of a group is successful, the Mesibo_onGroupCreated
listener function will be called with group profile.
func mesibo_(onGroupCreated profile: MesiboProfile?) {
alert("New Group Created", message: profile?.getName())
}
To create a group:
MesiboGroupSettings *settings = [MesiboGroupSettings new];
settings.name = @"My First Group";
settings.flags = 0;
[MesiboInstance createGroup:settings listener:self];
If the creation of a group is successful, the Mesibo_onGroupCreated
listener function will be called with group profile.
-(void) Mesibo_onGroupCreated:(MesiboProfile *) profile {
NSLog(@"New group");
}
To create a group:
api.createGroup("My Group From JS", 0, function(profile) {
console.log("group created");
});
You can now use this new group profile for messaging, adding more members or changing group name, description, picture, etc.
Adding members to a Group
You can add members, and admins to the group by calling addMembers
API of the group profile. You need to pass the addresses of the users to be added as group members, permissions to be granted and admin permissions if you are adding them as group admins.
// access groupProfile for group administration
MesiboGroupProfile gp = profile.getGroupProfile();
// create an array of member addresses to be added to the group
String[] members = {mRemoteUser.address};
// define permissions
MesiboGroupProfile.MemberPermissions mp = new MesiboGroupProfile.MemberPermissions();
mp.flags = MesiboGroupProfile.MEMBERFLAG_ALL;
mp.adminFlags = 0;
gp.addMembers(members, mp);
// access groupProfile for group administration
val gp = profile.groupProfile
// create an array of member addresses to be added to the group
val members = arrayOf(mRemoteUser!!.address)
// define permissions
val mp = MemberPermissions()
mp.flags = MesiboGroupProfile.MEMBERFLAG_ALL.toLong()
mp.adminFlags = 0
gp.addMembers(members, mp)
// access groupProfile for group administration
let gp = profile?.getGroupProfile()
// create an array of member addresses to be added to the group
var members: [AnyHashable] = []
members.append(mRemoteUser)
// define permissions
let mp:MesiboMemberPermissions = MesiboMemberPermissions();
mp.flags = UInt32(MESIBO_MEMBERFLAG_ALL);
mp.adminFlags = 0;
gp?.addMembers(members, permissions:mp)
// access groupProfile for group administration
MesiboGroupProfile *gp = [profile getGroupProfile];
// create an array of member addresses to be added to the group
NSMutableArray *members = [NSMutableArray new];
[members addObject:mRemoteUser];
// define permissions
MesiboMemberPermissions *mp = [MesiboMemberPermissions new];
mp.flags = MESIBO_MEMBERFLAG_ALL;
mp.adminFlags = 0;
[gp addMembers:members permissions:mp];
// access groupProfile for group administration
var gp = profile.getGroupProfile();
// create an array of member addresses to be added to the group
var members = ["123456", "112233"];
gp.addMembers(members, MESIBO_MEMBERFLAG_ALL, 0);