sshcheung / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

Entering null value for action-loc-key #99

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, according to the apple documentation, to remove the action key in a 
notification, one has to enter the value null for action-loc-key. However, due 
to the null check in the javapns library, entering a null value in the 
addCustomAlertActionLocKey method of PushNotificationPayload will remove the 
action-loc-key parameter from the JSON output. 

I understand that there are methods in previous versions of JavaPNS such as 
fromJSON which allows a raw json string to be used. However, these methods are 
no longer in the latest version of JavaPNS. Is there another way of inserting a 
null value for the action-loc-key argument as such:

    "action-loc-key":null

What is the expected output? What do you see instead?
The expected output should be a notification with only one close button.
However if I insert null, the launch button will be shown instead. 

Please provide any additional information below.

Original issue reported on code.google.com by Timothys...@gmail.com on 14 Jan 2012 at 2:04

GoogleCodeExporter commented 8 years ago
Apologies for my mistake. The fromJSON method is actually in the JavaPNS 2.2 
beta version. I have downloaded the beta version and used the fromJSON method 
but am unable to be successful despite having the "action-loc-key":null value 
in the JSON.

Original comment by Timothys...@gmail.com on 14 Jan 2012 at 3:06

GoogleCodeExporter commented 8 years ago
Fixed in r350 (2.2 Beta 2) now in the trunk.

Invoking addCustomAlertActionLocKey(null) will now produce the alternative 
output documented by Apple.

Original comment by sype...@gmail.com on 14 Jan 2012 at 10:15

GoogleCodeExporter commented 8 years ago
Wow many thanks for the fast response!
I just tried the new revision but it does not work although the JSON message 
does show "action-loc-key":null. Could it be because of org.JSON's JSONObject 
unable to accept a null input during runtime?

I'm currently using Netbeans 7.0.1 IDE with JDK 1.6 running on GlassFish Server 
3.1

Original comment by Timothys...@gmail.com on 15 Jan 2012 at 5:24

GoogleCodeExporter commented 8 years ago
I tested the fix using javapns.test.SpecificNotificationTests.test_Issue99(..) 
and did get a payload with the expected null value for action-loc-key, and the 
notification did reach my test device.  If it does not work in your case, could 
you please provide a full debug output so I can investigate further?  Thank you!

Original comment by sype...@gmail.com on 15 Jan 2012 at 5:33

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi, the full debug output is shown below. Everything seems to be fine but the 
right action button still appears in the app.

>java javapns.test.SpecificNotificationTests ip
hone_devQit.p12 password ded501488109739311f6a1a92896c98188429e410c408cd3d3b
899a6c25f1b7a simulation Issue99

TESTING ISSUE #99
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Payload size: 63
Payload representation: {"aps":{"alert":{"body":"Hello World!","action-loc-key":
null}}}
Payload size is only checked when it is complete
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
0 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSock
etFactory
56 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSoc
ket to gateway.sandbox.push.apple.com:2195
1507 [main] DEBUG javapns.notification.PushNotificationManager  - Initialized Co
nnection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 3ef810[SSL_NULL
_WITH_NULL_NULL: Socket[addr=gateway.sandbox.push.apple.com/17.172.238.209,port=
2195,localport=49934]]
1511 [main] DEBUG javapns.notification.PushNotificationManager  - Building Raw m
essage from deviceToken and payload
1512 [main] DEBUG javapns.notification.PushNotificationManager  - Built raw mess
age ID 1 of total length 108
1512 [main] DEBUG javapns.notification.PushNotificationManager  - Attempting to
send notification: {"aps":{"alert":{"body":"Hello World!","action-loc-key":null}
}}
1513 [main] DEBUG javapns.notification.PushNotificationManager  -   to device: d
ed501488109739311f6a1a92896c98188429e410c408cd3d3b899a6c25f1b7a
2172 [main] DEBUG javapns.notification.PushNotificationManager  - Flushing
2173 [main] DEBUG javapns.notification.PushNotificationManager  - At this point,
 the entire 108-bytes message has been streamed out successfully through the SSL
 connection
2174 [main] DEBUG javapns.notification.PushNotificationManager  - Notification s
ent on first attempt
2174 [main] DEBUG javapns.notification.PushNotificationManager  - Reading respon
ses
7177 [main] DEBUG javapns.notification.PushNotificationManager  - Closing connec
tion
All notifications pushed successfully (1):
  [1] transmitted {"aps":{"alert":{"body":"Hello World!","action-loc-key":null}}
} on first attempt to token ded50..f1b7a
ISSUE #99 TESTED

Original comment by Timothys...@gmail.com on 15 Jan 2012 at 6:50

GoogleCodeExporter commented 8 years ago
I re-ran the same test you did and got an alert with a single large "OK" 
button, as expected.  If I disable the 
"payload.addCustomAlertActionLocKey(null);" line in the test, I get an alert 
with two buttons as expected (Close and View).

Which button(s) do you see on your Hello World! notification?

Original comment by sype...@gmail.com on 15 Jan 2012 at 6:40

GoogleCodeExporter commented 8 years ago
Given the latest comments, I am re-opening the issue until we can determine 
that the fix was effective.

Original comment by sype...@gmail.com on 16 Jan 2012 at 11:35

GoogleCodeExporter commented 8 years ago
I see the buttons Close and Launch. 'Launch' is the default keyword for the 
action button in my IOS application (xcode 4.2) instead of 'View'.

I have tried the SpecificNotificationTests file on two different laptops but 
still yield the same results. I have also tried pushing the 
SpecificNotification to two different IOS phones with similar results.

I am beginning to believe that it is an Xcode issue because I am also unable to 
remove the action button on the UILocalNotification even though I have called 
hasAction = NO.

I will update once I figured the root cause.

Original comment by Timothys...@gmail.com on 17 Jan 2012 at 1:46

GoogleCodeExporter commented 8 years ago
Thank you!  I would like to close this issue before releasing version 2.2, so I 
will wait for your feedback.

Original comment by sype...@gmail.com on 17 Jan 2012 at 2:21

GoogleCodeExporter commented 8 years ago
this seems like an IOS5 problem : http://openradar.appspot.com/10308591

Original comment by Timothys...@gmail.com on 20 Jan 2012 at 11:10

GoogleCodeExporter commented 8 years ago
Indeed.  

Given the following reasons:

- the fix in r350 successfully produces the expected "action-loc-key":null 
property in a payload
- the Issue99 test apparently works on IOS4 (it did for me)
- the same test failing on IOS5 is documented as a known and unresolved issue 
in the OS and not the library

I will therefore close this issue report as fixed (on our part).  

Original comment by sype...@gmail.com on 20 Jan 2012 at 3:30