Last active
October 7, 2019 19:55
-
-
Save dlodeprojuicer/0dd9d8ef81e0076d42588db80f742639 to your computer and use it in GitHub Desktop.
Vue SMS receive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import moment from "moment"; | |
export default { | |
name: "home", | |
mounted() { | |
// There must be a better way of adding this addEventListener | |
document.addEventListener("deviceready", () => { | |
this.startWatch(); | |
}); | |
}, | |
data() { | |
return { | |
smsObj: {} | |
}; | |
}, | |
methods: { | |
startWatch() { | |
SMSReceive.startWatch( | |
() => { | |
document.addEventListener("onSMSArrive", e => { | |
this.processSMS(e.data); | |
}); | |
}, | |
() => { | |
this.watchError = "Error: SMSReceive did not start" | |
} | |
); | |
}, | |
processSMS(data) { | |
data.date = moment(data.date).format("MM-DD-YYYY HH:mm:ss"); | |
this.smsObj = data; | |
// Here you can get the OTP and pass it to your endpoint | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment