Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I know which sms is delivered? #82

Open
gamesover opened this issue Mar 12, 2021 · 4 comments
Open

How can I know which sms is delivered? #82

gamesover opened this issue Mar 12, 2021 · 4 comments

Comments

@gamesover
Copy link

gamesover commented Mar 12, 2021

DeviceEventEmitter.addListener('sms_onDelivery', (msg) => {
  console.log(msg);
});

The above works, just it only returns message "SMS delivered" .

If multiple sms were sent out, how can I know which sms delivery is successful, and which is failed?

Also, I found a strange issue.
1st, I send a sms, callback trigger once, and output 1 SMS delivered
2nd, I send a sms, callback trigger twice, and output 2 SMS delivered
...
10th, I send a sms, callback trigger 10th, and output 10 SMS delivered

@gamesover
Copy link
Author

gamesover commented Mar 14, 2021

update:

  1. about which is which sms, I resolved it by passing an additional parameter through putExtra and getExtra when broadcasting
  2. about callback is triggered multiple times, since code put registerbroadcast into autoSend method, so each time you call autoSend, you will register broadcast once. Thus, I move broadcasts out to initialize mthod.

Anyone interests, you may refer my fork.

@antoniomefa
Copy link

antoniomefa commented Apr 28, 2021

Hi @gamesover !
I'm trying to implement this listener in my project, but it don't show nothing. Can you gime me some help? Where can I put the listener, inside my sendSMS function or in a useEffect? My project sends a bulk of SMS, it works correctly but now I want to know which of them are received and which no. This is my sendSMS function:

const sendSMS = async () => { let increment = 0; const interval = 1000 * parseInt(timeInterval); setIsFinished(false); setIsSending(true); setLoadingText('Enviando...'); setIsLoading(true); var myLoop = setInterval(async function(){ await SmsAndroid.autoSend( globalContext.contacts[increment], message, (fail) => { console.log('Failed with this error: ' + fail); setErrorsCounter(errorsCounter => errorsCounter + 1); }, (success) => { setCounter(counter => counter + 1); //console.log('SMS sent successfully'); }, ); if (increment == globalContext.contacts.length-1) { clearInterval(myLoop); setIsLoading(false); setIsSending(false); setIsFinished(true); } increment++; },interval); };
Thanks!

@gamesover
Copy link
Author

Hi @antoniomefa . I have to change the source code of react-native-get-sms-android. When sending sms, I passed sms id. so when android broadcast sms sent/delivery status, it reports the result together with sms id. In this way, I know which sms is sent/delivered.

Detailed you may refer to my fork

@trungbmt
Copy link

Hi @gamesover , can you share the code :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants