java - How to send verification code back to my application from Parse Cloud after success? -


so i'm building signup procedure needs user verify phone number receiving code sms. i'm using parse backend system , i'm using twilio service comes included in parse take care of sms function. have been successful in sending verification code user's number.

this parse cloud code:

var client = require('twilio')('acb3....', '2b3....');  //send sms text message parse.cloud.define("sendverificationcode", function(request, response) {   var verificationcode = math.floor(math.random()*999999);      client.sendsms({         from: "+61437877758",         to: request.params.phonenumber,         body: "your verification code " + verificationcode + "."     }, function(err, responsedata) {         if (err) {           response.error(err);         } else {           response.success("success");         }     }); }); 

this code app:

hashmap<string, object> params = new hashmap<string, object>();                 params.put("phonenumber", usernumber);                 parsecloud.callfunctioninbackground("sendverificationcode", params, new functioncallback<string>() {                     public void done(string result, parseexception e) {                         if (e == null) {                             log.d("parse", result);                             intent = new intent(signupactivity.this, phoneverificationactivity.class);                             startactivity(i);                          } else {                             toast.maketext(signupactivity.this, "there problem connection", toast.length_long).show();                         }                     }                 }); 

now know how can send verification code android app parse cloud after success, tat can check verification code against code user puts in edittext

if (err) {                   response.error(err);                 } else { *//so code sending verification code goes here:*                   response.success("success");                 } 

do need use json , rest api?, how can call , grab verification code app?. appreciate help. thanks.

one way return in response.success...

response.success({ status: "success", verificationcode: ... }); 

another way, better way, not trust client this. store record of on object on server... when user enters validation code, call function check if valid. example of type of system can seen in old out-dated github login example: https://github.com/parseplatform/cloudcodeoauthgithubtutorial/blob/master/cloud/main.js#l116


Comments