Android SMSManager sendTextMessage-我收到Sentinent,但从未收到deliveryIntent

Android SMSManager sendTextMessage-我收到Sentinent,但从未收到deliveryIntent,android,sms,Android,Sms,我们正在使用Android上的SMSManager从设备向其他人发送文本消息 我们有报告称,用户未收到我们认为已发送的短信,这是因为Sentinent通过Activity.RESULT_OK被呼叫,但这似乎发生在本地短信服务只是将邮件排队等待发送时,而不一定是在真正发送时 所以我认为我们应该利用交付意图 这里的问题是,我总是收到Sentinent回调,但从来没有收到deliveryIntent回调 有什么想法吗? 代码如下,谢谢 // The intent action to b

我们正在使用Android上的SMSManager从设备向其他人发送文本消息

我们有报告称,用户未收到我们认为已发送的短信,这是因为Sentinent通过Activity.RESULT_OK被呼叫,但这似乎发生在本地短信服务只是将邮件排队等待发送时,而不一定是在真正发送时

所以我认为我们应该利用交付意图

这里的问题是,我总是收到Sentinent回调,但从来没有收到deliveryIntent回调

有什么想法吗? 代码如下,谢谢

        // The intent action to be unique so that we can have multiple
        // concurrent  pending intents.
        // http://developer.android.com/reference/android/app/PendingIntent.html
        String intentAction = TAG + "-" + callbackId;  // callbackId is unique
        Intent intent = new Intent(intentAction);
        intent.putExtra("phoneNumber", phoneNumber);
        intent.putExtra("callbackId", callbackId);
        intent.putExtra("message", message);

        PendingIntent sentPI = PendingIntent.getBroadcast(
            cordova.getActivity(), 0, intent, 0);

        cordova.getActivity().registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context ctx, Intent intent) {
                String sentToPhoneNumber = intent.getStringExtra("phoneNumber");
                String callbackId = intent.getStringExtra("callbackId");
                String message = intent.getStringExtra("message");
                int resultCode = getResultCode();
                int status = -1;
                String details = "";
                logger.log(Level.INFO, TAG + " SENT intent!! to: " +
                           sentToPhoneNumber + ", resultCode: " + resultCode);
                switch (resultCode) {
                    case Activity.RESULT_OK:
                        status = 0;
                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        details = "No service";
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        details = "Null PDU";
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        details = "Radio off";
                        status = 1;
                        break;
                }

                JSONObject obj = new JSONObject();
                try {
                    obj.put("status", status);
                    obj.put("details", details);
                    obj.put("phone_number", sentToPhoneNumber);
                    obj.put("message", message);
                } catch (JSONException e) {
                    throw new RuntimeException(e);
                }
                sendAsyncResultStatus(callbackId, obj);
                ctx.unregisterReceiver(this);
            }
        }, new IntentFilter(intentAction));

        // The intent action to be unique so that we can have multiple
        // concurrent  pending intents.
        // http://developer.android.com/reference/android/app/PendingIntent.html
        String deliveryIntentAction = TAG + "-Delivery-" + callbackId;
        Intent deliveryIntent = new Intent(deliveryIntentAction);
        deliveryIntent.putExtra("phoneNumber", phoneNumber);
        deliveryIntent.putExtra("callbackId", callbackId);
        deliveryIntent.putExtra("message", message);

        PendingIntent deliveryPI = PendingIntent.getBroadcast(
            cordova.getActivity(), 0, deliveryIntent, 0);

        cordova.getActivity().registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context ctx, Intent intent) {
                logger.log(Level.INFO, TAG + " DELIVERY intent YOYO!!");
                String sentToPhoneNumber = intent.getStringExtra("phoneNumber");
                String callbackId = intent.getStringExtra("callbackId");
                String message = intent.getStringExtra("message");
                String pdu = intent.getStringExtra("pdu");
                logger.log(Level.INFO, TAG + " DELIVERY intent!! to: " +
                        sentToPhoneNumber + ", pdu: " + pdu);

                JSONObject obj = new JSONObject();
                try {
                    obj.put("pdu", pdu);
                    obj.put("phone_number", sentToPhoneNumber);
                    obj.put("message", message);
                } catch (JSONException e) {
                    throw new RuntimeException(e);
                }
                sendAsyncResultStatus(callbackId, obj);
                ctx.unregisterReceiver(this);
            }
        }, new IntentFilter(deliveryIntentAction));

        smsManager.sendTextMessage(phoneNumber, null, message, sentPI, deliveryPI);

我可以想象,交付意图取决于退货收据的接收。网络提供商需要发送这些信息才能使您的程序正常运行


您可以通过打开“设置菜单”,浏览“SMS设置”并勾选“退货收据”框来完成此操作。

发货意图取决于某些承运商提供的发货报告

有些航空公司确实提供送货报告,有些则不提供。就运营商对DliveryReports的支持而言,分为三类

  • 提供商根本不提供DeliveryReport
  • 提供商总是提供虚假的DeliveryReport(即使数字无效,您也会得到OK报告)
  • 供应商提供交付报告
并发症不止于此。。。如果您的提供商(发送提供商)确实支持传递报告,那么您将在向同一运营商的订户发送邮件时获得传递报告。但是,当您在该运营商之外发送邮件时,您可能会收到或可能不会收到送达报告。在大多数情况下,你不会

这可能是由多种原因造成的,例如:

  • 目标提供程序不支持传递报告
  • 某些中间SMS网关不支持传递报告
  • 目的承运人或某些中间网关的交货报告与始发承运人的交货报告不兼容

就我所知,在这种情况下,交货报告不是一个保证信息。

不,对不起,不是这样。无论是否勾选“退货收据”框,交付意图都对我有效。