2016-12-02 35 views
3

我建立一個應用程序使用SMPP 3.4和工作以及發送短消息,但在一些手機我得到這個消息發送短消息:使用開放SMPP 3.4

無法顯示此消息

這是我的函數的源代碼:

public String sendMsg(JsonObject paramsIN) { 
    String smsMessage = paramsIN.getString("body"); 
    String smsDestination = paramsIN.getString("to"); 
    String smsSource = paramsIN.getString("from"); 
    String smscNAME = paramsIN.getString("smsc"); 

    SubmitSM request = new SubmitSM(); 
    SubmitSMResp response; 
    Session session; 
    try { 
     request.setSourceAddr(smsSource); 
     request.setDestAddr(smsDestination); 
     request.setShortMessage(smsMessage, "UTF-8"); 
     request.setRegisteredDelivery((byte) 3); 
     request.setDataCoding((byte) 4); // 4 
     request.assignSequenceNumber(true); 
     response = ((Session) sd.get(smscNAME)).submit(request); 
     logger.info("Submit response " + response.debugString()); 
     String messageId = response.getMessageId();  

     BigInteger bigInt = new BigInteger(messageId, 16); 

     return bigInt+""; 
    } catch (WrongLengthOfStringException e) { 
     logger.error(e); 
     return null; 
    } catch (PDUException e) { 
     logger.error(e); 
     return null; 
    } catch (TimeoutException e) { 
     logger.error(e); 
     return null; 
    } catch (WrongSessionStateException e) { 
     logger.error(e); 
     return null; 
    } catch (IOException e) { 
     logger.error(e); 
     return null; 
    } 
} 

請有人能幫幫我,謝謝

回答

1

將數據編碼設置爲0(網絡默認值)並使用您的提供商支持的任何字符集編碼身體。如果您必須猜測,請使用GSM默認字符集(jcharset包含編碼器)。如果你真的需要擴展字符集使用UTF-16BE並將數據編碼設置爲8.

+0

謝謝你的作品(y)。我在代碼 'request.setShortMessage(smsMessage,Data.ENC_UTF16_BE); request.setDataCoding((byte)0x08);' –

+0

嗨teppic感謝您的解決方案,但我有一個其他的問題,像一些其他的智能手機,如「三星galaxy G1王牌」我有這個消息「內容不支持」 –