【问题标题】:How to design body for sending large content in SMS?如何设计用于在 SMS 中发送大量内容的正文?
【发布时间】:2019-08-15 12:32:27
【问题描述】:

我正在尝试向手机发送短信。如何在正文中发送大数据?orderid 应该在线,产品名称在线, 在线价格,在线状态。如何安排身体?

var data2 = db.collection("UserProfile").doc(mauths)
  .get().then(doc =>
   {
      mobile= doc.data().MobileNumber;
      console.log("mobile",mobile);
       // Your Account Sid and Auth Token from twilio.com/console
       const accountSid = '======';
       const authToken = '=======';
       const client = require('twilio')(accountSid, authToken);
       client.messages
       .create({
         body: "Your " + pn + " has been cancelled " ,// need to more content line by line
         from: '+-=======',    
         to: mobile
         }) 
         .then(message => {
         });
 })

【问题讨论】:

  • 与其发送大消息,不如考虑发送小消息,并引用数据库中的其余数据。客户端可以直接查询数据库获取数据。

标签: android node.js google-cloud-firestore firebase-cloud-messaging


【解决方案1】:

我认为这对你有用。

  public static final String SMS_BUNDLE = "pdus";

public void onReceive(Context context, Intent intent) {
    Bundle intentExtras = intent.getExtras();

        if (intentExtras != null) {
        Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
        String smsMessageStr = "";
        for (int i = 0; i < sms.length; ++i) {
        String format = intentExtras.getString("format");
        SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i], format);

            String smsBody = smsMessage.getMessageBody().toString();
            String address = smsMessage.getOriginatingAddress();

            smsMessageStr += "SMS From: " + address + "\n";
            smsMessageStr += smsBody + "\n";
        }

        MainActivity inst = MainActivity.instance();
        inst.updateInbox(smsMessageStr);
    }
}

【讨论】:

    猜你喜欢
    • 2013-09-07
    • 2014-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多