6.1 Create Group

Using createGroup method a new group is created. The group can be either of type PUBLIC or PRIVATE, from the enum GroupType in BayunCore. The user creating the group automatically becomes a member of the group, with full authorization for complete group-management functionality for that group. The developer can choose to enforce more fine-grained access controls if desired.

Method parameters :
  • groupName: Group name(Optional)
  • groupType: Type of group.
  • success: Success block to be executed after group is successfully created.
  • failure: Failure block to be executed if group creation fails, returns BayunError.

Java
Kotlin
String groupName = "groupName";

// Callbacks for creating a group
Handler.Callback success = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        Log.d(TAG, "Group created successfully.");
        return false;
    }
}

Handler.Callback failure = new Handler.Callback() {
    @Override
    public boolean handleMessage(Message message) {
        String error = message.getData().getString("BayunError", "");
        if (error.equalsIgnoreCase(BayunError.ERROR_INTERNET_CONNECTION)) {

        } else if (error.equalsIgnoreCase(BayunError.ERROR_GROUP_TYPE_CANNOT_BE_NULL)) {

        } 
        return false;
    }
};

bayunCore.createGroup(groupName, BayunCore.GroupType.PUBLIC, success, failure);
val groupName = "groupName"

// Callbacks for creating a group
val success = Handler.Callback {
    Log.d(TAG, "Group created successfully.")
    false
}

val failure = Handler.Callback {
    val error = it.data.getString("BayunError", "")
    if (error == BayunError.ERROR_INTERNET_CONNECTION) {

    } else if (error == BayunError.ERROR_GROUP_TYPE_CANNOT_BE_NULL) {

    }
    false
}

bayunCore.createGroup(groupName, BayunCore.GroupType.PUBLIC, success, failure)

results matching ""

    No results matching ""