Thursday, August 1, 2013

MDM-APNS Pusher JAVA

I created MDM APNS Pusher library for JAVA.
Download
Using this library you can send APNS "wake up " to many devices.

**********Please follow these steps to implement it.****************

1.Initialing with certificate-location and password

APNSInitiator apns=new APNSInitiator("/home/mayuran/workspace/IOSMDM/src/certificates/MDM_ WSO2 Inc_Certificate.p12", "pasword");

Note:Here you push certificate should be in .p12 format with its respective password.

2.Calling the method to push

apns.pushingToAPNS(devicesInfoList);

Note: Here devicesInfoList is the set of devicetokens,magictokens .
example :
[{magictoken=7DDAFFA8-B282C-45CB-B3C2-7B71850F1803, devicetoken=L6lUGSrOIx5jnHtQgAWqBELzpkXhGexWiHVHfC2fzwZ8=}, {magictoken=7DDAFFA8-B82C-45CB-B3C2-7B71850F1803, devicetoken=L6lUGSrOIx5jnHtQgAWqBELzpkXhGexWiHVHfCfzwZ8=}]



additional information :
you can create devicesInfoList by

Map<String,String> device 1 Attributes = new HashMap<String, String>(){{
   put("devicetoken", "L6lUGSrOIx5jnHtQgAWqBELzpkXhGexWiHVHfCfzwZ8=");
   put("magictoken", "7DDAFFA8-B82C-45CB-B3C2-7B71850F1803");
}};

ArrayList<Map<String,String>> devicesInfoList = new ArrayList<Map<String,String>>(10);
devicesInfoList.add(device1 Attributes);
devicesInfoList.add(device2 Attributes);
      






        

18 comments:

  1. Thank you for your post. But could you tell me, what are the device token and magic token? Device UUID and ???

    ReplyDelete
    Replies
    1. Once you enrolled ,the device sent you Device token ,Pushmagic token
      Here
      Device token : using this push notification will reach the device.

      Push magic token : using this MDM client authenticate the push notification and allow APNS to trigger the MDM system.

      Device UUID : Since device UUID unique to each device,it helps you map the service calls to devices .
      For example 1000 devices are trying to connect to your MDM system at the same time.In this case you can send(to a device) a UUID in the request payload and get the same UUID in response payload (from device).
      So easily you can differentiate and mange service calls to devices.

      I hope now you can understand :)

      Delete
    2. Thank you for your quick reply, Mayuran!
      I'm studying MDM with only documents because I'm waiting a Enterprise account.
      Could you have a post for how do use javapns to send a command to APNS? I searched a long time on Google, but only see posts for sending a notification, not MDM command.
      Thank you so much!

      Delete
    3. same as ANPS app push notification service , MDM also use same service with little modification on it .
      I explain what to send to APNS server for MDM support.
      Please refer

      Delete
    4. Tried the above piece of code but device is still not being able to receive notifications.I have both pushmagic and device token value coming from the device.

      Delete
    5. @deepti you must probably check for your APNS certificate and password.
      I hope you made the devicesInfoList as show above.
      FYI this is a working code and pretty straight forward

      Delete
  2. Hi. I have a question.
    If i want send a particular command via MDM, for example "DeviceLock", how can i do this?
    this is the code for push : ApnsNotification goodMsg = svc.push(goodToken, payload_MDM);
    but where i can insert the command for lock the device??
    many thanks in advance!

    ReplyDelete
    Replies
    1. Good question !!
      You must know first how apple constructed MDM flow.
      Actually you don't send a device control command to APNS (example device lock).
      You will use the APNS payload to "wake up" the device ,
      Remember we send only device Device token(to find device), push magic token(authenticate MDM capabilities on your device) to APNS server.
      So the APNS finds the device using token and wake up the device.
      Once device wake up , it will request to your server (server url) for any pending CONTROL commands.Server in response sends control commands like wipe , lock , etc to the device.

      here server url, you supposed to mention during the enrolment.

      Let me know if you have doubts in that

      Delete
    2. Thanks for the answer!
      So, if i want send a Control command, first, i must "wake up" the device via APNS, then, the device "ask" if the server have some control command. (of course the device know the server address after the ernollment phase).
      And here the server send the command throught a a xml file (plist).
      It's correct?

      Delete
    3. yes..you are right...server can send all the payloads (lock,wipe,wifi,vpn,apn,etc) in a plist file(xml formatted).Once device receives the payload,it will execute immediately.

      Delete
    4. Do you have any information( or document) about the new features for MDM with IOS 7(and IOS 7.1)?
      Thanks in advance:)

      Delete
    5. i think you have to check this site for iOS7 added mdm features.
      http://www.apple.com/sg/ios/business/

      Delete
  3. Thanks. I would like to find some papers or detailed information about this new features , but inside the Apple site i can't find nothing . Usually there are very stingy about infromation.
    But very thanks. ;)

    ReplyDelete
  4. lol yea Apple dont give enough info to developers as usual.
    I have done MDM about a year ago.that time was iOS 6.

    Later they released iOS 7 with MDM features Per app VPN , SSO , open in management. It seems very interesting things happening in enterprise MDM world.
    I think you must put your question in apple developer forum and get solutions to your needs.

    Good luck :)

    ReplyDelete
    Replies
    1. Thank you ;) I have a last doubt, i hope that you can answer ;)
      If i install a profile with, for ex., only youTube, and before the installation i have , for ex, only Facebook, after the profile instalaltion, of course,i don't see facebook more.
      But the application has been uninstalled or was deleted just the logical link with the app, and there still stay on the phone??

      Very thanks ;)

      Delete
    2. well..it happens only in configuration profile installation, which can replay the exiting configuration profile , if you try to install a new one.
      So first configuration profile contains (ex. Camera disabling) can be removed / replaced with new one.so you do not see any configuration installed through the first config file.

      Delete
    3. Very thanks for your answer....;)

      Delete