다음을 통해 공유


사용자 지정 문자 집합을 사용하여 SMS 보내기

텍스트 모드 인터페이스에서 지원되지 않는 시나리오를 달성하기 위해 PDU(원시 메시지 프로토콜 데이터 단위)에 액세스해야 하는 경우 Windows 8, Windows 8.1 및 Windows 10 수신된 SMS 메시지를 보내고 읽는 PDU 모드를 사용하도록 설정합니다.

다음과 같은 경우 PDU 모드 SMS 인터페이스를 사용해야 할 수 있습니다.

  • 3GPP TS 23.038에 정의된 대로 국가 언어 단일 시프트 테이블 또는 국가별 언어 잠금 Shift 테이블을 사용하여 수신된 SMS를 보내거나 읽으려면

  • 각 세그먼트에 대해 서로 다른 문자 집합을 사용하여 여러 부분으로 구성된 SMS를 보내려면

PDU 모드 인터페이스를 사용하여 SMS 메시지를 보내는 JavaScript 코드 예제

function smsDevicePDUSend()
{
  if (smsDevice !== null)
  {
    // Defines a binary message
    var smsMessage = new Windows.Devices.Sms.SmsBinaryMessage();
    var messsagePdu = “0011000B914152828377F90000AA0CC8F71D14969741F977FD07”;
    var messagePduByteArray = hexToByteArray(messsagePdu);
    smsMessage.setData(messagePduByteArray);

    if (smsDevice.cellularClass === Windows.Devices.Sms.CellularClass.gsm)
    {
      smsMessage.format = Windows.Devices.Sms.SmsDataFormat.gsmSubmit;
    }
    else
    {
      smsMessage.format = Windows.Devices.Sms.SmsDataFormat.cdmaSubmit;
    }
    var sendSmsMessageOperation = smsDevice.sendMessageAsync(smsMessage);

    sendSmsMessageOperation.done(function (reply) {
      WinJS.log("Sent message in PDU format", "sample", "status");
    }, errorCallback);
}

// Used to convert hex PDU to byte array for sending SMS using PDU //mode
function hexToByteArray(hexString)
{
  var result = [];
  var hexByte = "";
  var decByte = 0;
  for (var i = 0; i < hexString.length; i = i + 2) {
    hexByte = hexString.substring(i, i + 2);
    decByte = parseInt(hexByte, 16);
    result.push(decByte);
  }
  return result;
}

PDU 모드 인터페이스를 사용하여 수신된 SMS 메시지를 읽는 JavaScript 코드 예제

function smsDeviceRead()
{
  try
  {
    if (smsDevice !== null)
    {
      var messageStore = smsDevice.messageStore;
      var messageID = “1” // select a Message Id to read 

      // Check for a valid ID number
      if (isNaN(messageID) || messageID < 1 || messageID > messageStore.maxMessages)
      {
        WinJS.log("Invalid ID number", "sample", "error");
        return;
     }

     var getSmsMessageOperation = messageStore.getMessageAsync(messageID);

     // Display message when get is completed
     getSmsMessageOperation.done(smsMessageReadSuccess, errorCallback);
     } 
  }
  catch (err) {
    // handle error
  }
}

function smsMessageReadSuccess(smsMessage)
{
  try
  {
    if (smsMessage instanceof SmsBinaryMessage) {
    var format  = smsMessage.format;
    var pduData = smsMessage.getData(); // byte array 
  }
  catch (err)
  {
    WinJS.log("SMS did not set up: " + err, "sample", "error");
  }
}

SMS 앱 개발