如何设计发送短信内容的主体?

时间:2019-03-25 09:38:58

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

我正在尝试通过手机发送短信。如何在体内发送大数据?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 => {
         });
 })

1 个答案:

答案 0 :(得分:-2)

我认为这对您有用。

  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);
    }
}