【问题标题】:how to get data from device uuid and send it as sms in ionic framework如何从设备 uuid 获取数据并将其作为 ionic 框架中的短信发送
【发布时间】:2015-05-10 17:33:47
【问题描述】:

我正在为客户端开发一个移动应用程序,该应用程序的主要功能是从设备获取数据并通过短信发送,但我使用 cordova 设备插件来获取设备 uuid,但不知道如何将其发送为短信,请帮忙。这是我的 HTML:`

angular.module('starter.controllers', [])

.controller('AppCtrl', function() {})

.controller('DeviceCtrl', function($ionicPlatform, $scope, $cordovaDevice) {
$ionicPlatform.ready(function() {
$scope.$apply(function() {
// sometimes binding does not work! :/
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
// getting device infor from $cordovaDevice
var device = $cordovaDevice.getDevice();

        $scope.manufacturer = device.manufacturer;
        $scope.model = device.model;
        $scope.platform = device.platform;
        $scope.uuid = device.uuid;

    });

});
})
<ion-view view-title="Device Information">

    <ion-content>
        <div class="card">
            <div class="item item-divider">
                Your device information!
            </div>
            <div class="item item-text-wrap">
                <ul class="list">
                    <li class="item">
                        Manufacturer : {{manufacturer}}
                    </li>
                    <li class="item">
                        Model : {{model}}
                    </li>
                    <li class="item">
                        Platform : {{platform}}
                    </li>
                    <li class="item">
                        UUID : {{uuid}}
                    </li>
                </ul>
            </div>
            <div class="item item-divider text-right">
                 
            </div>
        </div>
    </ion-content>
</ion-view>

` 使用上面的代码,我可以获得设备 uuid,但现在的问题是如何发送 uuid 信息并将其作为短信发送

【问题讨论】:

    标签: cordova ionic cordova-plugins


    【解决方案1】:

    使用 Cordova SMS 插件发送短信。 (https://github.com/cordova-sms/cordova-sms-plugin/blob/master/readme.md) 这是工作流程

    1.通过设备插件获取设备uuid

    2.将此作为短信代码的参数发送。 将此代码放在device.uuid.之后

    var deviceid=device.uuid;
    //pass the deviceid
    
     sendsms(deviceid);
    
    function sendsms(deviceid){
     var app = {
        sendSms: function() {
            var number ="mobile no";
            var message ="deviceid is"+deviceid;
            alert(number);
            alert(message);`
    
            //CONFIGURATION
            var options = {
                replaceLineBreaks: false, // true to replace \n by a new line, false by default
                android: {
                    intent: 'INTENT'  // send SMS with the native android SMS messaging
                    //intent: '' // send SMS without open any other app
                }
            };
    
            var success = function () { alert('Message sent successfully'); };
            var error = function (e) { alert('Message Failed:' + e); };
            sms.send(number, message, options, success, error);
        }
    };
    }
    

    【讨论】:

    • 请@shammon,你能告诉我代码吗?谢谢
    • 非常感谢@shammon 我会试试的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 2015-02-12
    • 2019-01-16
    • 2023-01-02
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    相关资源
    最近更新 更多