title: iOS MDM Device Polling and APNs Certificate
body: <p>I'm developing an iOS MDM Server as my project and I have almost completed.</p>
  
  <p>I created all the necessary files manually including the mobileconfig file and installed the profile. </p>
  
  <p>The device polls the URL mentioned in Server URL often with an Idle message.I read that the Idle message indicates that the device is checking the server for commands and we can send plist response as a command.</p>
  
  <p>My question is, if all the devices poll the MDM Server frequently, what is need for .pem file and APNs certificate. Should we send push notification to the device like below like we send push notifications to our iOS apps.</p>
  
  <pre><code>{
      "aps": {
           "id": 10,
           "message": "Hello world!",
           "from": "Ram"
      }
  }
  </code></pre>
  
  <p>If this is what we should do, what should we send in the payload?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>I found out the solution for sending push notifications.</p>
  
  <pre><code>com.notnoop.apns.ApnsService apnsservice = com.notnoop.apns.APNS.newService().withCert(&lt;pushCertStream&gt;,&lt;pushCertPass&gt;).withProductionDestination().build();
  apnsservice.push(token, com.notnoop.apns.APNS.newPayload().mdm(pushMagic)).build());
  </code></pre>
  
  <p>When push notification is sent like this, the device responds with an Idle Message and we can send commands to the device.</p>
  
  <p><strong>Few more doubts :</strong></p>
  
  <p>1) When does apple check the SSL Certificate of the profile? I'm sure it checks during profile installation because my profile installation has failed many times due to wrong SSL Certificat. Does Apple also check the SSL Certificate when sending push notification as I have noticed a class <strong>com.notnoop.exceptions.InvalidSSLConfig</strong>? Does it check whether the server sending push notification has the SSL Certificate specified in the profile?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>When server send push notification to the device, the device responds with an Idle Message to the URL specified in Server URL. What happens if the SSL Certificate is invalid at this point. Does it produce an error?</p>
  
  <p>2) Can multiple servers have the same push notification certificate to reduce the load on a single server to send push notification and send commands to devices? Will there be any conflict?</p>
  
  <p>3) Is there any limit to the no. of push notifications sent using a single push notification certificate? If not, can it handle any number of push notifications?</p>
  
  <p>4) Can the Check-in URL and Server URL in the profile be different?</p>
  
  <p><strong>EDIT</strong> 
  Can the Check-in URL and Server URL be of different servers i.e ., </p>
  
  <p>CheckIN URL : <a href="https://www.domainone.com/MDM/" rel="nofollow noreferrer">https://www.domainone.com/MDM/</a></p>
  
  <p>Server URL  : <a href="https://www.domaintwo.com/MDM/" rel="nofollow noreferrer">https://www.domaintwo.com/MDM/</a></p>
  
  <p>5) <a href="https://stackoverflow.com/questions/48076126/ios-mdm-certificates-expiry">First question in this link</a><strong>(Least important)</strong> Though the solution talks about expiration of SSL Certificate, it does not say about changing of SSL Certificate.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>When a push notification certificate is renewed, how does a device with profile already installed update the certificate details in the device's profile?</p>