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

Multiple recipients problem #25

Closed
spyjo opened this issue Mar 19, 2015 · 14 comments
Closed

Multiple recipients problem #25

spyjo opened this issue Mar 19, 2015 · 14 comments
Assignees

Comments

@spyjo
Copy link

spyjo commented Mar 19, 2015

Hello,

I have a problem with sending SMS to multiple recipients, I tried with separating with , or ; but only the first number listed is receiving the message in both cases.

Here is the code:

var options = {
  replaceLineBreaks: false,
  android: {
      intent: ''
  }
};

var success = function () { alert('sent !'); };
var error = function (e) { alert('error ! '+e); };
sms.send('010000000,020000000,030000000', 'my message', options, success, error);

I tried on Android 4.4 or Android 5.0
Is there something else I can try or is this a bug ?

Thank you

@dbaq
Copy link
Member

dbaq commented Mar 19, 2015

hey @spyjo,

could you try to use an array instead please:

 var phones = ['01000000','02000000','03000000']; 

let me know if it works.

the string parameter should work though, I need to look into it.

@dbaq dbaq self-assigned this Mar 19, 2015
@agarrharr
Copy link
Member

Should it work as a string though? I see no reason to support that. It makes sense to me that it should either be a single number as a string, or an array of strings.

@spyjo
Copy link
Author

spyjo commented Mar 19, 2015

I tried with an array but it's the same result, only the first number receive the message

I added a debug line in www/sms.js in send():

console.log('sms.send | phone = '+phone+' , typeof phone = '+typeof(phone)+' , type tostring = '+Object.prototype.toString.call(phone));

and the result is:

I/chromium(30156): [INFO:CONSOLE(23)] "sms.send | phone = 01000000, 02000000, 03000000 , typeof phone = object , type tostring = [object Array]"

so the array of phone numbers is ok on the javascript side before being sent to the java function

@dbaq
Copy link
Member

dbaq commented Mar 19, 2015

@Aharris88, I don't think it makes sense to maintain that neither.

@spyjo, I can confirm the issue. I will look into it.

@dbaq
Copy link
Member

dbaq commented Mar 19, 2015

the issue comes from here https://github.com/cordova-sms/cordova-sms-plugin/blob/master/src/android/Sms.java#L139

we need to iterate over the list of numbers and call http://developer.android.com/reference/android/telephony/SmsManager.html#sendTextMessage(java.lang.String, java.lang.String, java.lang.String, android.app.PendingIntent, android.app.PendingIntent) for each.
The tricky part here, is to execute the callback only when all the messages have been sent.

@dbaq
Copy link
Member

dbaq commented Mar 19, 2015

That raises some questions about the plugin behavior and consistency.

if you use the plugin with intent = "INTENT" and phones = ['number1', 'number2'], it is sending only one group message (like iOS)

but if intent = "" and phones = ['number1', 'number2'], it would send 2 separate messages, so inconsistency here.

IMHO, we should clearly explain the difference between a group message and a simple message to several recipients. Also explain that group messages are not available within the current intent (unless if there is a solution that I don't know).

@Aharris88, thoughts?

@spyjo
Copy link
Author

spyjo commented Mar 19, 2015

Ok thank you for looking into it :)
Tell me if you need me to do some tests

@agarrharr
Copy link
Member

I think it should be consistent. So it could be that sending an array of numbers with or without intent, should send a group message. But if you send an array of numbers without intent, maybe you could set an option to send them individually.

@dbaq
Copy link
Member

dbaq commented Mar 19, 2015

Sending a group message without intent is "impossible" (I haven't found anything online about it yet)

@spyjo, what is your use case here? Group message or n times the same message?

@spyjo
Copy link
Author

spyjo commented Mar 20, 2015

I need to send the same message to a list of contacts, without showing the default sms app, and then display one confirmation that all messages are sent.
It's not necessarily a group message I think, I'm not sure

@spyjo
Copy link
Author

spyjo commented Mar 28, 2015

To update this issue, for now I have fixed my problem with a "for" on each number to send messages, counting error and success, and detect when I received the last callback (total success+errors = total numbers) to display my popup "SMS are sent".

For your previous question, I can confirm I do not want to send a group message, but anyway if you need it in your plugin I think that in the android dev documentation the right function is sending an MMS with sendMultimediaMessage() which seems to allow multiple recipients in group.

@dbaq
Copy link
Member

dbaq commented Mar 29, 2015

@spyjo that's definitely what you should you for now.

what we should do here:

  • update the documentation to say that an array of phone numbers will send a group message (MMS) and that's not supported for INTENT='' on android
  • add MMS support Adding Support for MMS #14 to send group messages

@dbaq
Copy link
Member

dbaq commented May 28, 2015

Closing this one, it will be managed in #14

@dbaq dbaq closed this as completed May 28, 2015
@shadabs22
Copy link

how to solve same issue in ios, only message is sent to first number only.
Plz....

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

4 participants