Skip to content

Instantly share code, notes, and snippets.

@dlodeprojuicer
Last active October 7, 2019 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlodeprojuicer/0dd9d8ef81e0076d42588db80f742639 to your computer and use it in GitHub Desktop.
Save dlodeprojuicer/0dd9d8ef81e0076d42588db80f742639 to your computer and use it in GitHub Desktop.
Vue SMS receive
<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