
com.togocms.pns.api.AndroidNotification Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of togopns Show documentation
Show all versions of togopns Show documentation
Push Notification System (Apple/Google)
The newest version!
package com.togocms.pns.api;
import java.util.ArrayList;
import java.util.List;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.MulticastResult;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
public class AndroidNotification extends AbstractNotification {
public List send() throws Exception {
Sender sender = new Sender(getSecretKey());
Message message = new Message.Builder().addData("TogoMessage", getTitle()).addData("TogoInfo", getPayload()).build();
MulticastResult multicastResult = sender.send(message, getTokens(), 0);
List badTokens = new ArrayList();
int i = 0;
for (Result result : multicastResult.getResults()) {
if (result.getErrorCodeName() != null) {
badTokens.add(getTokens().get(i));
}
i++;
}
return badTokens;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy