Reputation: 7249
I want to send same message to multiple devices in android using GCM
. Currently I am able to send push notification on single device in java. But I want to send it to multiple devices.
so how can I do this?
my single device code is:
try{
Sender sender = new Sender(GOOGLE_SERVER_KEY);
Message message = new Message.Builder().timeToLive(30)
.delayWhileIdle(true).addData(GOOGLE_MESSAGE_KEY,
userMessage).build();
result = sender.send(message, token, 1);
} catch (Exception e) {
System.out.println(e);
}
Any help or idea are highly appreciated.
Thanks
Upvotes: 1
Views: 844
Reputation: 7249
multiple device code is:
List<String> tokens=new ArrayList<String>();
Sender sender = new Sender(GOOGLE_SERVER_KEY);
Message message = new Message.Builder().timeToLive(30)
.delayWhileIdle(true).addData(GOOGLE_MESSAGE_KEY,
userMessage).build();
sender.send(message, tokens, 1);
Upvotes: 1