}//for (String username : usernames)
int i=0;
for(Integer pushProfile : pushProfiles) {
HashMap<Factory.VendorOS,IPushServer> allVendors= Factory.getAllIstances();
IPushServer apnServer = allVendors.get(VendorOS.IOS);
apnServer.setConfiguration(getPushParameters(pushProfile));
IPushServer gcmServer = allVendors.get(VendorOS.ANDROID);
gcmServer.setConfiguration(getPushParameters(pushProfile));
if(iosToken.size()>0) {
for(List<String> thousandUsersApple : Lists.partition(iosToken, 1000)){
withError[i]=apnServer.send(message, thousandUsersApple, bodyJson);
}
i++;
}
if(androidToken.size()>0) {
for(List<String> thousandUsersAndroid: Lists.partition(androidToken,1000)){ //needed for the GCM sending limit
withError[i]=gcmServer.send(message, thousandUsersAndroid, bodyJson);
}
i++;
}
}