pkeslin / javapns

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

Implementation for {"mdm":"<PushMagic>"} #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I looked into issue # 37 and also looked into the 
"javapns.notification.management" package. I could not find an api to send 
{"mdm":"<PushMagic>"} to apple.
I want to implement MDM solution using javapns. I have installed the 
mobileConfig  and have the deviceToken and pushMagic String. Next I want to 
send {"mdm":"<PushMagic>"} and then the other commands.

Is this possible using javapns and if yes - is there a sample or some inputs of 
how to do it?
Issue #37 says it is possible to send mdm payloads but I could not figure how. 

I really appreciate any help on this.

Thanks,
Ashutosh

Original issue reported on code.google.com by ashutosh...@gmail.com on 19 Jan 2012 at 8:13

GoogleCodeExporter commented 9 years ago
As far as I understand, the 'management' package currently provides support 
only for the OTA config part of MDM, because no public documentation could be 
found to extend that support for the rest of MDM.  If you can provide a 
reference to official documentation on MDM, we'll gladly take a look at it and 
see if JavaPNS can be adapted to support it.  Otherwise, you are always free to 
construct your payloads yourself by instantiating a 
"javapns.notification.Payload" object and populating it yourself.

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

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks for the response:

OK - I extended the Payload and am using it to send mdm payload.

as per logs everything went well - but I didnt hear back from the device on the 
mdm url.

I am wondering if I am doing the right thing. I am still using the Push.payload 
api which needs device token. Is that correct? - Is there something else that I 
should be doing? 
String token = "12345";
String pushMagic = "ewewe-34234-wewewe-4343";

Payload mdnPayload  = new MDNPayload();// MDNPayload extends from Payload
 mdnPayload.addCustomDictionary("mdm", pushMagic);
 log.debug("payload created:"+mdnPayload.getPayload().toString());
  List<PushedNotification> notifications =  Push.payload(mdnPayload, "APN-di.p12", "pwd", false, token);
 NotificationTest.printPushedNotifications(notifications);
               for(PushedNotification notification : notifications){
                   System.out.println("successful:"+ notification.isSuccessful()); 
//                 notification.getException().printStackTrace();
               }

logs :
0 [main] DEBUG javapns.notification.Payload  - Adding custom Dictionary [mdm] = 
[9E092882-FC02-4B39-A5F2-6BB4BAE9B65A]
0 [main] DEBUG javapns.notification.Payload  - Adding custom Dictionary [mdm] = 
[9E092882-FC02-4B39-A5F2-6BB4BAE9B65A]
0 [main] DEBUG com.apn.DIPush  - payload 
created:{"mdm":"ewewe-34234-wewewe-4343"}
0 [main] DEBUG com.apn.DIPush  - payload 
created:{"mdm":"ewewe-34234-wewewe-4343"}
514 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocketFactory
514 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocketFactory
623 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
623 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Initialized 
Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 
d70d7a[SSL_NULL_WITH_NULL_NULL: 
Socket[addr=gateway.sandbox.push.apple.com/17.149.34.55,port=2195,localport=3446
]]
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Initialized 
Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195]: 
d70d7a[SSL_NULL_WITH_NULL_NULL: 
Socket[addr=gateway.sandbox.push.apple.com/17.149.34.55,port=2195,localport=3446
]]
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Building Raw 
message from deviceToken and payload
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Building Raw 
message from deviceToken and payload
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Built raw 
message ID 1 of total length 91
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Built raw 
message ID 1 of total length 91
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Attempting to 
send notification: {"mdm":"ewewe-34234-wewewe-4343"}
1465 [main] DEBUG javapns.notification.PushNotificationManager  - Attempting to 
send notification: {"mdm":"ewewe-34234-wewewe-4343"}
1465 [main] DEBUG javapns.notification.PushNotificationManager  -   to device: 
014fbe0bb2446f201b8d473ebebef8f8b6187f89cd988c0b513793e27b258a83
1465 [main] DEBUG javapns.notification.PushNotificationManager  -   to device: 
014fbe0bb2446f201b8d473ebebef8f8b6187f89cd988c0b513793e27b258a83
1667 [main] DEBUG javapns.notification.PushNotificationManager  - Flushing
1667 [main] DEBUG javapns.notification.PushNotificationManager  - Flushing
1667 [main] DEBUG javapns.notification.PushNotificationManager  - At this 
point, the entire 91-bytes message has been streamed out successfully through 
the SSL connection
1667 [main] DEBUG javapns.notification.PushNotificationManager  - At this 
point, the entire 91-bytes message has been streamed out successfully through 
the SSL connection
1667 [main] DEBUG javapns.notification.PushNotificationManager  - Notification 
sent on first attempt
1667 [main] DEBUG javapns.notification.PushNotificationManager  - Notification 
sent on first attempt
1667 [main] DEBUG javapns.notification.PushNotificationManager  - Reading 
responses
1667 [main] DEBUG javapns.notification.PushNotificationManager  - Reading 
responses
6655 [main] DEBUG javapns.notification.PushNotificationManager  - Closing 
connection
6655 [main] DEBUG javapns.notification.PushNotificationManager  - Closing 
connection
All notifications pushed successfully (1):
  [1] transmitted {"mdm":"ewewe-34234-wewewe-4343"} on first attempt to token 014fb..58a83

Original comment by ashutosh...@gmail.com on 20 Jan 2012 at 9:51

GoogleCodeExporter commented 9 years ago
Everything seems to be in order:  the final payload content is printed in the 
log and does not appear to be malformed in any way, the APNS service is 
contacted successfully, the 91-bytes message is completely transmitted to the 
remote server, no error-response packet is detected, and the notification is 
finally considered pushed. 

So, as far as the library is concerned, your test seems to be working fine.  
So, if the device is not reacting to the notification, this is something you 
will most likely have to investigate on the client side, and seek help on 
forums related to MDM.

Since JavaPNS does provide the ability to meet the needs specified in the 
original issue report,  I will be closing this issue shortly.  If some other 
reliability problem exists and can be tied to the library itself, a separate 
issue can be opened.

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

GoogleCodeExporter commented 9 years ago
Closing as explained in comment 4.

Original comment by sype...@gmail.com on 23 Jan 2012 at 4:39

GoogleCodeExporter commented 9 years ago
ok - thanks for help. I have one question. in the above example - I could send 
the pushmagic but I used deviceToken to do the push.
api: Push.payload(mdnPayload, "APN-di.p12", "pwd", false, token);

Is there an api where I dont ust the token. I think we dont need token for 
pushing the mdn payload since they need pushmagic.

Original comment by ashutosh...@gmail.com on 24 Jan 2012 at 12:33

GoogleCodeExporter commented 9 years ago
I can't help you there, I do not have any MDM documentation.  Since JavaPNS is 
designed primarily for APNS, and since APNS wouldn't make sense without a 
token, all push methods require a device token.  

As I said, I don't have access to any official MDM documentation (which is I 
believe protected under NDA), and so maybe I'm missing something here, but I 
don't understand why you wouldn't need a token to push pretty much anything...  
surely you need to tell Apple which devices you're talking to, no?

Again, if you find any official and accessible MDM documentation we can take a 
look at, we'll gladly take a look at it and see if JavaPNS requires any 
modifications to make it more compatible with that technology.  If not, there's 
not much that can be done here.

Original comment by sype...@gmail.com on 24 Jan 2012 at 4:44