user3807691
user3807691

Reputation: 1304

meteor methods on server not being called

I am developing a meteor app. It was working fine but out of nowhere a strange error came into being. I have a file under the server folder where I have defined all my meteor methods. I am calling them using Meteor.call from the client side.

The issue is that I am not able to call my server methods anymore.

Following code was working fine yesterday :

HTML code :

<section class="body_section">
        <form>
          <div class="container">

            <div class="box"> <h2 class="verify_number">Verify your phone number</h2></div>
            <div class="box"> <p class="center_txt"> We will send an SMS message to verify your phone number. </p></div>
            <div class="box"> <span class="isdcode">+ 91</span><input myattr="mobileNo" type="tel" class="input-txt signin" id="signin" name="mobNumber" placeholder="Mobile Number" pattern="[6789][0-9]{9}" onKeyUp="numbersonly()" value ='' required>
            </div>
          </div>
          <footer class="signformFooter">
            <div class="container">
              <input type="submit" class="next_btn" id="verifyNumber" value="NEXT"/>
            </div>
          </footer>
        </form>
    </section>

Corresponding js event code :

'submit form' : function(event){
  event.preventDefault();

  var numb = '+91' + event.target.mobNumber.value;

 if(confirm('OTP would be sent to ' + numb)){
    Meteor.call("sendSMS", numb, function(error, res){
      if(!error){ 
        Router.go('verifyMobile',{
          mobNo : numb
        });
      }
      else
        alert(error)
    });
}
}

Server side code :

sendSMS : function(mobile){
    var otp = UserOTP.findOne({mobNo : mobile});
    if(otp == undefined){
        otp = Math.floor(Math.random()*9000) + 1000;
        UserOTP.insert({
            mobNo : mobile,
            OTP : otp,
            createdAt : new Date()
        })  
    }
    else
        otp = otp.OTP;
    var msg91 = require("msg91")("", "", "" );
    var message = '4 Digit Verification Code for kNOwDoubt ' + otp;

    msg91.send(mobile, message, function(err, response){
        if(err){
            console.log('otp not sent to : ' + mobile + " " + err);

        }
        else{
            console.log('otp ' + otp + ' sent to ' + mobile + ' with transactional route ' + response);

        }
    });


    return true;
},

The strange thing is the app is running absolutely fine on web-browsers. The issue is only when i run the app on android (not yet tested on ios).

Meteor version : 1.5

command to run on android : sudo -E meteor run android-device --allow-superuser --settings server/settings.json

I belive I have a very trivial error somewhere. Any help will be appreciated.

Thanks!

Upvotes: 1

Views: 77

Answers (1)

user3807691
user3807691

Reputation: 1304

So I ran the app on another machine(PC). It ran fine there. The issue was with sdk version. I deleted my previous sdk versions and reinstalled them. Working fine now

Upvotes: 1

Related Questions