2012-06-11 5 views
0

장치에서 tokenUpdate를 가져온 후 푸시 알림을 보내려고합니다. 하지만 푸시 알림을 보낼 때처럼 작동하지 않는다고 생각합니다. 기기에서 응답을받지 못했습니다. MDM 명령을 확인하기 위해 서버를 폴링한다고 가정하지 않습니까? 대신 토큰 업데이트를 계속받습니다.푸시 알림이 iPhone 장치로 전송되지 않았습니다.

String cToken = token; 
      String cAlert = message; 

      // Ready to create the push notification 
      byte[] buf = new byte[256]; 
      MemoryStream ms = new MemoryStream(); 
      BinaryWriter bw = new BinaryWriter(ms); 



      char[] tokenChars = token.ToCharArray(); 
      byte[] deviceTokenBytes = new byte[tokenChars.Length]; 
      for (int i=0; i < deviceTokenBytes.Length; i++) 
      { 
       deviceTokenBytes[i] = Convert.ToByte(tokenChars[i]); 
      } 

      // byte[] deviceToken = HexToData(cToken); 
      bw.Write(deviceTokenBytes); 


      // Create the APNS payload - new.caf is an audio file saved in the application bundle on the device 
      //string msg = "{\"aps\":{\"alert\":\"" + cAlert + "\",\"badge\":" + iBadge.ToString() + ",\"sound\":\"new.caf\"}}"; 
      string msg = "{\"mdm\":\"+ mPushMagic +"\"}"; 

      // Write the data out to the stream 
      // bw.Write((byte)msg.Length); 
      bw.Write(msg.ToCharArray()); 
      bw.Flush(); 

      if (sslStream != null) 
      { 
       sslStream.Write(ms.ToArray()); 
       return true; 
      } 

      return false; 
     } 

업데이트 : 나는 pushmagic ID

답변

1

나는 시작하는 당신의 MDM 메시지에서 갈매기를 제거하는 것을 권 해드립니다에서 '<'을 제거했다.

+0

괜찮습니다. 그러나 클라이언트는 여전히 응답하지 않습니다 :/ – michelle

+0

Convert.ToByte가 무엇인지 모르겠지만 자바 코드에는 다음과 같은 것들이 있습니다 :'BASE64Decoder decoder = new BASE64Decoder(); byte [] decodedBytes = decoder.decodeBuffer (device.getDeviceToken()); StringBuffer buf = new StringBuffer(); for (int i = 0; i Abstractec

+0

그건 아니야 :/내가 Encoding.ASCII.GetBytes (tokenChars)로 변경하고 아직 아무것도 – michelle

관련 문제