With SMSRetriever API you can easily retrieve SMS for your APP without needing SMS read permission. This API can be useful for mobile phone verification in your app.
SMSRetriever.getAppHash()
.then((result) => {
console.log(JSON.stringify(result));
//Send the result to your application backend
})
.catch((error) => {
console.error(JSON.stringify(error));
});
...
//After receiving the SMS with the correct hash code, this will handle it.
SMSRetriever.startWatching()
.then((result) => {
console.log(JSON.stringify(result));
})
.catch((error) => {
console.error(JSON.stringify(error));
});
window.SMSRetriever.getAppHash()
.then((result) => {
console.log(JSON.stringify(result));
//Send the result to your application backend
})
.catch((error) => {
console.error(JSON.stringify(error));
});
...
window.SMSRetriever.startWatching()
.then((result) => {
console.log(JSON.stringify(result));
})
.catch((error) => {
console.error(JSON.stringify(error));
});
window.SMSRetriever.getAppHash()
.then((result) => {
console.log(JSON.stringify(result));
//Send the result to your application backend
})
.catch((error) => {
console.error(JSON.stringify(error));
});
...
window.SMSRetriever.startWatching()
.then((result) => {
console.log(JSON.stringify(result));
})
.catch((error) => {
console.error(JSON.stringify(error));
});
(<any>window).SMSRetriever.getAppHash()
.then((result) => {
console.log(JSON.stringify(result));
//Send the result to your application backend
})
.catch((error) => {
console.error(JSON.stringify(error));
});
(<any>window).SMSRetriever.startWatching()
.then((result) => {
console.log(JSON.stringify(result));
})
.catch((error) => {
console.error(JSON.stringify(error));
});
window.SMSRetriever.getAppHash()
.then((result) => {
console.log(JSON.stringify(result));
//Send the result to your application backend
})
.catch((error) => {
console.error(JSON.stringify(error));
});
...
window.SMSRetriever.startWatching()
.then((result) => {
console.log(JSON.stringify(result));
})
.catch((error) => {
console.error(JSON.stringify(error));
});
getAppHash(): Promise<string>
Get the hash code of your app.
Afeter you get the hash code, you need to send your application hash in SMS when you are sending from your backend.
SMS Example: "<#> Your App code is:1234 YOUR_HASH_CODE"
startWatching(): Promise<any>
Retrieve sms for your app.
Note: Without the correct hash code, your app won't recieve the message.