Hi everyone,
I am doing Login & Register and need a good phone number validation.
I tried to use “Phone Number Validation” as following link:
http://market.ionic.io/user/297645
I need to change our SMS gateway
I had to use HTTP GET request for use this API as following:
function sendSMS($to, $msg)
{
$url = ‘{MY API URL}’;
[
‘query’ => [
‘username’ => ‘MY USERNAME’,
‘pass’ => ‘MY PASS’,
‘from’ => ‘MY NUMBER’,
‘to’ => $to,
‘msg’ => $msg,
]
]);
}
The controllers as two item:
1- Verify
2- Phone number
angular.module(‘phonenumber’)
.controller(‘VerifyCtrl’, function($scope, $ionicHistory, PhoneService, $timeout, $http, $state) {
$scope.backButton = function() {
$scope.verifyData = {};
$ionicHistory.goBack();
};
$scope.verifyData = {
phone: PhoneService.getPhone(),
code: ‘’,
pattern: /^[0-9]{6}$/
};
$scope.counter = 60;
$scope.disabledupdate = true;
var mytimeout = null;
$scope.onTimeout = function() {
if($scope.counter <= 1) {
$scope.counter = ‘’;
$scope.disabledupdate = false;
$timeout.cancel(mytimeout);
return;
}
$scope.counter–;
mytimeout = $timeout($scope.onTimeout, 1000);
};
mytimeout = $timeout($scope.onTimeout, 1000);
$scope.xverify = function() {
$scope.verifyData.code = “”;
$scope.errorVerify = “”;
$scope.wrongVerify = false;
};
$scope.verifyupdate = function() {
$scope.loading = true;
$scope.verifyData.code = “”;
$scope.errorVerify = “”;
$scope.wrongVerify = false;
// api is the link where you can send
// var api1 = ‘http://your-server.com/api/verifyupdate’;
// $http.post(api1, {email: $scope.verifyData.email}).then(function(response) {
// if(response.data.success == true) {
$scope.loading = false;
$scope.counter = 60;
$scope.disabledupdate = true;
mytimeout = $timeout($scope.onTimeout, 1000);
// } else {
// $scope.errorSuccess = true;
// }
// });
};
$scope.submit = function() {
$scope.loading = true;
// api is the link where you can send
// var api2 = 'http://your-server.com/api/verify';
// $http.post(api2, {email: $scope.verifyData.email, code: $scope.verifyData.code}).then(function(response) {
// if(response.data.success == true) {
// $state.go('dashboard');
$scope.loading = false;
// } else {
// $scope.loading = false;
// $scope.errorVerify = "item-error";
// $scope.wrongVerify = true;
// }
// });
};
})
angular.module(‘phonenumber’)
.controller(‘PhoneCtrl’, function($scope, PhoneService, $http, $ionicActionSheet, $state) {
var getLanguage = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
var splitLanguage = getLanguage.toLowerCase().split("-");
var userLanguage = splitLanguage[0];
$scope.userCountry = splitLanguage[1];
$scope.countries = countryData;
angular.forEach($scope.countries, function(value){
if(value.iso2 == $scope.userCountry) {
$scope.initIso2 = value.iso2;
$scope.initFlag = value.flag;
}
});
$scope.phoneData = {
country: {
name: '',
iso2: '',
flag: ''
},
phone: {
number: '',
isocode: '',
dialcode: ''
}
};
$scope.validPhone = false;
$scope.change = function() {
if(!$scope.phoneData.phone.number) {
$scope.validPhone = false;
} else {
$scope.validPhone = true;
PhoneService.setPhone($scope.phoneData.phone.number);
}
};
$scope.submit = function() {
$scope.loading = true;
// api is the link where you can send
// var api = 'http://your-server.com/api/phonenumber';
// $http.post(api, {language: userLanguage, country: $scope.phoneData.country.iso2, phone: $scope.phoneData.phone.number}).then(function(response) {
// if(response.data.success == true) {
$state.go('verify');
$scope.loading = false;
// } else {
// $scope.loading = false;
// $scope.errorSuccess = true;
// }
// });
};
})
I’m new to using with Ionic Framework and I don’t have any view on the development of my SMS-Gateway API into the app.
I would be happy and appreciate if someone can help me in this regard.
Thanks in advance.