Closed GoogleCodeExporter closed 8 years ago
Is it possible you already added a simple alert in your payload, before trying
to add a custom one? If you add a simple alert, the payload will link a String
to the "alert" key; but if you try to add a custom alert afterwards, it will
need to link a JSON object to the same "alert" key, which it won't be able to
do because you already added a String to that key.
Original comment by sype...@gmail.com
on 2 Oct 2011 at 2:59
Committed 2.0 RC Revision 002 to SVN with an improvement regarding this issue.
If one tries to add a custom alert to a PushNotificationPayload (though any of
the addCustomAlert... methods) that already contains a simple alert, a more
precise exception is now thrown indicating that a simple alert was already
added to the payload (and vice-versa).
Original comment by sype...@gmail.com
on 3 Oct 2011 at 1:20
Please ignore revision link in comment above, it got linked automatically by
Google Code to an unrelated project entry.
javapns 2.0 RC.002 is available in SVN and not at the link in the comment above.
Original comment by sype...@gmail.com
on 3 Oct 2011 at 2:05
This is the code that i am using:
PushNotificationPayload x = new PushNotificationPayload();
x.addCustomAlertBody("message body");
x.addBadge(11);
x.addSound("default");
x.addCustomDictionary("entity-id", "4e88438978b8f20c187997c5");
x.addCustomDictionary("entity-type", "USER");
Push.payload(x, "cert.p12", "xxxxx", false, "71f87aa.......e");
The above code throws the exception.
Original comment by ajmannat...@gmail.com
on 3 Oct 2011 at 6:11
I cannot replicate the problem with the code you provided. I inserted my own
keystore, keystore password and device token, and your code successfully pushed
a notification to my device.
If that code really throws an exception for you, could you please provide a
complete stack trace (with line numbers)? Thank you.
Original comment by sype...@gmail.com
on 3 Oct 2011 at 2:00
I'm still getting the error. Here is the stack trace that i get:
Exception in thread "main" org.json.JSONException: JSONObject["alert"] not
found.
at org.json.JSONObject.get(JSONObject.java:517)
at org.json.JSONObject.getJSONObject(JSONObject.java:611)
at javapns.notification.PushNotificationPayload.getCustomAlert(PushNotificationPayload.java:119)
at javapns.notification.PushNotificationPayload.addCustomAlertBody(PushNotificationPayload.java:134)
at Test.main(Test.java:34)
Original comment by ajmannat...@gmail.com
on 3 Oct 2011 at 5:43
You do not appear to be using the latest build as suggested in comment 3.
Could you please download the latest build of the library from SVN and try
again? Thanks!
Original comment by sype...@gmail.com
on 3 Oct 2011 at 6:46
Sorry, but I am not really sure how to pull that revision through here.
Original comment by ajmannat...@gmail.com
on 5 Oct 2011 at 2:56
A shortcut is available on the Requirements wiki page (requirement #1, nightly
build), but here is the complete procedure:
1) click on the Source panel in this web site
2) click on Browse
3) navigate down to svn > branches > javapns2
4) click the latest version of the library (javapns_2.0_RC.jar) on the right
5) click "View raw file" in the File info section of the page (your download
will start)
Original comment by sype...@gmail.com
on 5 Oct 2011 at 3:39
Thanks a lot for your help.
Its working perfectly now.
Very much appreciated!
Original comment by ajmannat...@gmail.com
on 5 Oct 2011 at 4:27
Good news! Thanks!
Closing as Fixed in 2.0 RC.002.
Original comment by sype...@gmail.com
on 5 Oct 2011 at 4:30
Original issue reported on code.google.com by
ajmannat...@gmail.com
on 2 Oct 2011 at 9:52