【问题标题】:Appcelerator titanium - send smsAppcelerator钛 - 发送短信
【发布时间】:2011-09-09 22:16:51
【问题描述】:

我正在使用 appcelerator Titan 创建一个移动 (iphone/android) 应用程序。有什么方法可以让应用使用 appcelerator Titan 向任何给定号码发送短信?

【问题讨论】:

    标签: sms titanium send appcelerator appcelerator-mobile


    【解决方案1】:

    如果您只想使用自己的信息打开短信应用,可以使用以下方法:

    Ti.Platform.openURL("sms:01234567891&body=hey");
    

    注意数字和正文都是可选的。

    【讨论】:

      【解决方案2】:

      有一个功能可以用来发送短信:

      var SMS_SENT     = -1,
          SMS_NOT_SENT =  0;
      
      /**
       * Open an SMS dialog with the given message.
       * If the SMS is sent, run the onSuccess callback.
       *
       * @message {text}      the text you want to send
       * @callback {function} the funciton you want to run on success
       **/
      function openSmsDialog(message, onSuccess) {
          if (Ti.Platform.osname === 'android') {
              var intent = Ti.Android.createIntent({
                  action: Ti.Android.ACTION_VIEW,
                  type:   'vnd.android-dir/mms-sms'
              });
              intent.putExtra('sms_body', message);
      
              var _onClose = function(activityResult) {
                  if (activityResult.resultCode === SMS_SENT && onSuccess) {
                      onSuccess();
                  }
              };
      
              Ti.Android.currentActivity.startActivityForResult(intent, _onClose);
          } else {
              var smsModule = require("com.omorandi");
      
              var smsDialog = smsModule.createSMSDialog({
                  messageBody: message
              });
      
              if (onSuccess) {
                  smsDialog.addEventListener('complete', onSuccess);
              }
          }
      }
      

      要使此代码在 iOS 上运行,您必须使用 com.omorandi 模块。对于 android,您不需要任何模块。

      【讨论】:

      • 能否请您告知以下代码的作用? Ti.Android.currentActivity.startActivityForResult(intent, _onClose);
      【解决方案3】:

      刚刚在谷歌搜索其他内容时发现了您的问题。所以我想我会回答,以防将来有人遇到这个Q。

      Appcelerator Marketplace 中有一个用于发送 SMS 消息的模块:https://marketplace.appcelerator.com/apps/6521?1019589994

      【讨论】:

        【解决方案4】:

        这是一个很棒的模块。

        仅支持安卓。无需 usr 交互会自动发送短信

        https://github.com/omorandi/TiAndroidSMS

        【讨论】:

          【解决方案5】:

          【讨论】:

            【解决方案6】:

            如果您不想付费,这里有一个适用于 iOS 的短信模块:

            http://developer.appcelerator.com/question/97961/ios-sms-dialog-module

            您需要遵循他的指南,但您应该能够让它发挥作用。对于 android,您可以简单地调用带有“sms://”+phoneNumber 或类似名称的 URL。

            【讨论】:

              【解决方案7】:

              Appcelerator 有一组模块,如果您是其中一个合作伙伴计划的成员,您可以使用这些模块。它包括一个短信模块:

              http://www.appcelerator.com/products/titaniumplus/

              【讨论】:

                猜你喜欢
                • 2019-04-24
                • 2017-06-22
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多