iOS MDM – 如何在设备响应有效响应后closures或停止连接

我们正在构build一个iOS MDM服务器来pipe理iOS设备。 以下是涉及将iOS设备注册到MDM服务器的步骤

  1. 发送注册configuration
  2. 执行SCEP
  3. 发送MDM服务器证书。
  4. 创buildAPNS证书。
  5. 发送推送通知到设备。

设备收到推送通知,并联系MDM服务器的“serverUrl”。 它响应状态=“空闲”如下所示

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Status</key> <string>Idle</string> <key>UDID</key> <string><udid-of-device></string> </dict> </plist> 

为了响应这个命令获取设备信息如下发送。

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Command</key> <dict> <key>RequestType</key> <string>DeviceInformation</string> <key>Queries</key> <array> <string>UDID</string> <string>DeviceName</string> <string>OSVersion</string> <string>ModelName</string> <string>IMEI</string> </array> </dict> <key>CommandUUID</key> <string>command-for-the-session</string> </dict> </plist> 

设备回应如下所示的设备信息

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CommandUUID</key> <string>command-for-the-session</string> <key>QueryResponses</key> <dict> <key>DeviceName</key> <string>iPhone</string> <key>IMEI</key> <string>01 353150 432467 8</string> <key>ModelName</key> <string>iPhone</string> <key>OSVersion</key> <string>7.1</string> <key>UDID</key> <string><udid-device></string> </dict> <key>Status</key> <string>Acknowledged</string> <key>UDID</key> <string><udid-device></string> </dict> </plist> 

该stream程按要求工作。 在此之后,我想结束与设备的连接,因为没有更多的东西要发送到设备。

我的查询是如何停止或closures此连接之后,我们从该设备收到该CommandUUID有效的详细信息。 它不断调用MDM服务器的url,并没有结束连接。

我曾尝试发送一个空plist停止连接,但没有运气。

请帮助。

谢谢阅读。!

设备将通过发送以下命令不断向您的服务器查询新命令:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Status</key> <string>Idle</string> <key>UDID</key> <string><udid-of-device></string> </dict> </plist> 

在这种情况下,如果你没有任何命令,你应该返回一个空的HTTP 200。 这告诉设备它应该停止轮询,直到您发送下一个推送通知。

这是我在java中发送和空的响应。

如果一切顺利,响应状态默认为200。

代码发送空回应:

 response.setStatus(200); // set status explicitly in case device polls to the mdm server OutputStream outStream = response.getOutputStream(); outStream.write(new byte[0]); outStream.close(); 

和服务器日志相同如下:

 iPhone mdmd[302] <Notice>: (Note ) MDM: mdmd starting... iPhone mdmd[302] <Notice>: (Note ) MDM: Looking for managed app states to clean up iPhone profiled[303] <Notice>: (Note ) profiled: Service starting... iPhone mdmd[302] <Notice>: (Note ) MDM: Network reachability has changed. iPhone mdmd[302] <Notice>: (Note ) MDM: Network reachability has changed. iPhone mdmd[302] <Notice>: (Note ) MDM: Push token received. iPhone mdmd[302] <Notice>: (Note ) MDM: Push token received. iPhone mdmd[302] <Notice>: (Note ) MDM: Received push notification. iPhone mdmd[302] <Notice>: (Note ) MDM: Polling MDM server https://myserver-url:port/server for next command. iPhone mdmd[302] <Notice>: (Note ) MDM: Transaction completed. Status: 200 iPhone mdmd[302] <Notice>: (Note ) MDM: Attempting to perform MDM request: DeviceInformation iPhone mdmd[302] <Notice>: (Note ) MDM: Command Status: Acknowledged iPhone mdmd[302] <Notice>: (Note ) MDM: Polling MDM server https://myserver-url:port/server for next command. iPhone profiled[303] <Notice>: (Note ) profiled: Service stopping. iPhone mdmd[302] <Notice>: (Note ) MDM: Transaction completed. Status: 200 iPhone mdmd[302] <Notice>: (Note ) MDM: Server has no commands for this device. iPhone mdmd[302] <Notice>: (Note ) MDM: mdmd stopping.