Closed GoogleCodeExporter closed 9 years ago
instead of looping thru each iphone id and naming the device 'iPhone'...
loop thru each iphone id and add it to the pushmanager as a unique device.
Then send all the notifications in one shot.
like:
for device in database
pushManager.addDevice("iPhone", device.getDeviceToken());
client=pushManager.getDevice( device.name );
end for
pushManager.sendNotification(client, payLoad);
for device in database
pushManager.removeDevice(device.name);
end for
Original comment by idbill.p...@gmail.com
on 9 Dec 2010 at 5:41
Hi,
Thanks for your reply. By looking at the above code skeleton, wouldn't client
represent the last device in the for loop. Please advise.
Original comment by pilotj...@gmail.com
on 9 Dec 2010 at 6:50
I'm assuming device is a row coming back from your database call.
And device.name is unique to that device
and device.token is the unique token for said device row.
Original comment by idbill.p...@gmail.com
on 9 Dec 2010 at 7:03
Yes, what you have assumed is correct. I think you did not understand my
question...
In the below line
pushManager.sendNotification(client, payLoad);
doesn't client represent the last device present in the DB and so won't the
notification be sent to only that device.
Please let me know...
Original comment by pilotj...@gmail.com
on 9 Dec 2010 at 7:10
I'm very busy at the moment, so please read the wiki, there are examples
already provided.
The important part, is to only initialize the connection once, send all the
notifications, then close the connection.
Bill
Original comment by idbill.p...@gmail.com
on 9 Dec 2010 at 7:30
Okay..Thanks. I did change the code as per your code skeleton and as expected
only the last device returned from the DB got notified.
I think it is because you have put
pushManager.sendNotification(client, payLoad);
outside the for loop. I couldn't locate any example on the wiki for sending
bulk pushes. Please re-examine you suggested code and reply back when you get
time
Thanks
John
Original comment by pilotj...@gmail.com
on 9 Dec 2010 at 8:19
I did not understand the line made in Comment #1
"Then send all the notifications in one shot."
Since you are calling
pushManager.sendNotification(client, payLoad);
outside the loop. So won't only the device represented in 'client' be notified.
Please advice
Original comment by pilotj...@gmail.com
on 10 Dec 2010 at 2:11
See:
http://code.google.com/p/javapns/wiki/MultipleClientsExample
I have not tested the code, but it should have everything in the right place.
Someone is working on a database connection piece that may streamline this
process, but I do not know the status at this time.
Original comment by idbill.p...@gmail.com
on 11 Dec 2010 at 7:08
Original comment by idbill.p...@gmail.com
on 11 Dec 2010 at 7:08
Thanks. I have implemented your template into my code.
Original comment by pilotj...@gmail.com
on 13 Dec 2010 at 3:29
Comment by MrPatol, Dec 15 (2 days ago)
missing line before
pushManager.sendNotification( client, aPayload );
should have:
Device client = pushManager.getDevice(user.getUsername());
Original comment by idbill.p...@gmail.com
on 17 Dec 2010 at 6:00
example has been updated
Original comment by idbill.p...@gmail.com
on 17 Dec 2010 at 6:01
Closing issue since example for javapns 1.x has been updated, and because
javapns 2.0 provides direct support for this.
Original comment by sype...@gmail.com
on 7 Sep 2011 at 1:13
Original issue reported on code.google.com by
pilotj...@gmail.com
on 9 Dec 2010 at 3:28