createChannel方法返回null
List<String> channelMembersList = new ArrayList<String>();
channelMembersList.add(p.getMobile());
channelMembersList.add("9567600846");
channelMembersList.add("8089117582");
final ChannelInfo channelInfo = new ChannelInfo("GroupName",channelMembersList);
channelInfo.setType(Channel.GroupType.PRIVATE.getValue().intValue());
runOnUiThread(new Runnable() {
@Override
public void run() {
channel = ChannelService.getInstance(WelcomeActivity.this).createChannel(channelInfo);
}
});
这里,尽管创建了ChannelInfo对象,但通道对象始终为null。有人请帮忙......
答案 0 :(得分:1)
我们添加了一个异步任务,您可以使用此异步任务来创建组/通道传递组成员,组名和一些详细信息等详细信息是可选的。
<强>更新强>
AlChannelCreateAsyncTask.TaskListenerInterface channelCreateTaskListener = new AlChannelCreateAsyncTask.TaskListenerInterface() {
@Override
public void onSuccess(Channel channel, Context context) {
Log.i("Group","Group response :"+channel);
}
@Override
public void onFailure(ChannelFeedApiResponse channelFeedApiResponse, Context context) {
}
};
List<String> groupMembersUserIdList = new ArrayList<>();
groupMembersUserIdList.add("user1");
groupMembersUserIdList.add("user2");
groupMembersUserIdList.add("user3");//Note:while creating group exclude logged in userId from list
ChannelInfo channelInfo = new ChannelInfo("Group name",groupMembersUserIdList);
channelInfo.setType(Channel.GroupType.PUBLIC.getValue().intValue()); //group type
channelInfo.setImageUrl(""); //pass group image link URL
//channelInfo.setChannelMetadata(channelMetadata); //Optional option for setting group meta data
//channelInfo.setClientGroupId(clientGroupId); //Optional if you have your own groupId then you can pass here
AlChannelCreateAsyncTask channelCreateAsyncTask = new AlChannelCreateAsyncTask(context,channelInfo,channelCreateTaskListener);
channelCreateAsyncTask.execute();
答案 1 :(得分:0)
使用 applozic
创建群组创建具有特定组类型
的组Channel.GroupType.PRIVATE.getValue()。的intValue()
类型为的公共组:Channel.GroupType.PUBLIC.getValue()。intValue()
打开组类型为:Channel.GroupType.OPEN.getValue()。intValue()
注意:组元数据是可选的
为已创建组,左侧组,已删除组,已删除组,组图标已更改以及组名称等消息设置组元数据。
注意:如果频道元数据设置为空字符串,则不会向组/频道中的其他用户发送通知。
ChannelMetadata channelMetadata = new ChannelMetadata();
channelMetadata.setCreateGroupMessage(ChannelMetadata.ADMIN_NAME + " created " + ChannelMetadata.GROUP_NAME);
channelMetadata.setAddMemberMessage(ChannelMetadata.ADMIN_NAME + " added " + ChannelMetadata.USER_NAME);
channelMetadata.setRemoveMemberMessage(ChannelMetadata.ADMIN_NAME + " removed " + ChannelMetadata.USER_NAME);
channelMetadata.setGroupNameChangeMessage(ChannelMetadata.USER_NAME + " changed group name " + ChannelMetadata.GROUP_NAME);
channelMetadata.setJoinMemberMessage(ChannelMetadata.USER_NAME + " joined");
channelMetadata.setGroupLeftMessage(ChannelMetadata.USER_NAME + " left group " + ChannelMetadata.GROUP_NAME);
channelMetadata.setGroupIconChangeMessage(ChannelMetadata.USER_NAME + " changed icon");
channelMetadata.setDeletedGroupMessage(ChannelMetadata.ADMIN_NAME + " deleted group " + ChannelMetadata.GROUP_NAME);
以下占位符将被替换
ChannelMetadata.ADMIN_NAME : admin name of the group
ChannelMetadata.USER_NAME : user name of the user
ChannelMetadata.GROUP_NAME : group name
的文档
答案 2 :(得分:0)
5.34版中
ChannelService.getInstance(WelcomeActivity.this).createChannel(channelInfo)
分配变量AlResponse
。
并且AlResponse
在ChannelService.getInstance(WelcomeActivity.this).createChannel(channelInfo)
之后为空