无法通过Android App中的Sinch向多个收件人发送邮件

时间:2016-01-09 14:34:00

标签: android sinch

我已尝试在我的Android应用中发送Sinch消息,并且在发送给单个收件人时效果很好

MyClass的

String userId= "abc";
CustomReplyMessageBuild customMessage = new CustomReplyMessageBuild();
customMessage.setRecepientIDs(userId);
Map<String, String> m1 = new HashMap<String, String>();
m1.put(“param1", "YES");
m1.put(“param2”, 123);
m1.put(“param3", time);
customMessage.setHeaders(m1);
messageService.sendMessage(customMessage);

为myBean

private List<String> RecepientIds = new ArrayList<String>();
private Map map;
private void setHeaders(Map map) {
this.map = map;}
private void setRecepientIDs(String id) {
        this.RecepientIds.add(id);
    }

为MyService

private MessageClient messageClient = client.getMessageClient();
public void sendMessage(MyClass.CustomReplyMessageBuild conf_message){`
if(messageClient != null){
    WritableMessage message = new WritableMessage(conf_message);
    messageClient.send(message);
   }
}

但是当我尝试传递收件人ID列表时(对于广播类型的功能),我无法在另一端收到该消息。

MyBroadcastClass

List<String> broadcastIdList;
String recepId = "a,b,c";
CustomReplyMessageBuild customMessage = new CustomReplyMessageBuild();
broadcastIdList = Arrays.asList(recepId.split(","));
customMessage.setRecepientIdList(broadcastIdList);
Map<String, String> m1 = new HashMap<String, String>();
m1.put(“param1", "YES");
m1.put(“param2”, 123);
m1.put(“param3", time);
customMessage.setHeaders(m1);
messageService.sendMessage(customMessage);

MyBroadcastBean

private List<String> RecepientIds = new ArrayList<String>();
private Map map;
private void setHeaders(Map map) {
this.map = map;}
private void setRecepientIdList(List<String> idList) {
this.RecepientIds.addAll(idList);
}

如果您发现错误或发布示例代码段或链接以解决此问题,请告知我们。 万分感谢!

1 个答案:

答案 0 :(得分:1)

要向多个收件人发送邮件,请尝试以下构造函数:

// Create a WritableMessage and send to multiple recipients

    WritableMessage message = new WritableMessage(
        {"recipient user id 1", "recipient user id 2"},
        "Hello recipients! How are you?");  

// Send it

     messageClient.send(message);