Comments (13)
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 [email protected]
on 9 Dec 2010 at 5:41
from javapns.
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 [email protected]
on 9 Dec 2010 at 6:50
from javapns.
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 [email protected]
on 9 Dec 2010 at 7:03
from javapns.
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 [email protected]
on 9 Dec 2010 at 7:10
from javapns.
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 [email protected]
on 9 Dec 2010 at 7:30
from javapns.
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 [email protected]
on 9 Dec 2010 at 8:19
from javapns.
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 [email protected]
on 10 Dec 2010 at 2:11
from javapns.
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 [email protected]
on 11 Dec 2010 at 7:08
from javapns.
Original comment by [email protected]
on 11 Dec 2010 at 7:08
- Added labels: Type-Other
- Removed labels: Type-Defect
from javapns.
Thanks. I have implemented your template into my code.
Original comment by [email protected]
on 13 Dec 2010 at 3:29
from javapns.
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 [email protected]
on 17 Dec 2010 at 6:00
from javapns.
example has been updated
Original comment by [email protected]
on 17 Dec 2010 at 6:01
from javapns.
Closing issue since example for javapns 1.x has been updated, and because
javapns 2.0 provides direct support for this.
Original comment by [email protected]
on 7 Sep 2011 at 1:13
- Changed state: Fixed
from javapns.
Related Issues (20)
- thread terminated after reached max msg send HOT 3
- Exception reporting not working for multiple payloads
- Responses not read? HOT 1
- Javapns Communication exception:Connection refused to ConnectionToAppleServer
- support for title-loc-key (ios 8.2)
- Unable to connect APNS - CommunicationException - java.net.ConnectionException : Communication Timed Out HOT 2
- Duplicate notifications being sent out at high rate
- Add content-available to PushNotificationPayload
- Do you support VoIP push notifications?
- javaapns does not supports log4j 2
- Exception java.net.SocketException
- Javapns Notifications SSL Exceptions and Closed Sockets HOT 2
- thead lake
- Version of LGPL used is not documented
- 256 byte max size is outdated for iOS7 HOT 1
- Compatibility with Java 8 HOT 1
- which is latest version for JavaPNS jar?
- Remote host closed connection during handshake
- ProxyManager not have the setProxyBasicAuthorization method
- New Category tag for Actionable Notification
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javapns.