如何从设备uuid获取数据并将其作为sms在离子框架中发送

时间:2015-05-10 17:33:47

标签: cordova ionic cordova-plugins

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



// Top-level build file where you can add configuration options common to all sub-projects/modules.  

buildscript {  
repositories {  
    jcenter()  
}  
dependencies {  
    classpath 'com.android.tools.build:gradle:1.2.2'  

    // NOTE: Do not place your application dependencies here; they  belong  
    // in the individual module build.gradle files  
}  
}  

 allprojects {  
 repositories {  
    jcenter()  
}  
} 

{{1}}




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

1 个答案:

答案 0 :(得分:1)

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

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

2.将此作为SMS代码的参数发送。     将此代码放在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);
    }
};
}