babariviere / flutter_sms

SMS library for flutter
MIT License
87 stars 158 forks source link

Cannot send using 2nd sim slot #34

Open litzbalane2017 opened 6 years ago

litzbalane2017 commented 6 years ago

When sending using the 1st sim slot, the code bellow works.

SmsSender sender = new SmsSender();
SimCardsProvider provider = new SimCardsProvider();
card = await provider.getSimCards();
SmsMessage message = new SmsMessage("address", "content");
sender.sendSms(message, simCard: card.first);

However, when using card.last, in order to send via the 2nd sim slot like this:

sender.sendSms(message, simCard: card.last);

I always get this error.

E/flutter ( 6443): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception: E/flutter ( 6443): PlatformException(#01, message state change error, null) E/flutter ( 6443): #0 _rootHandleUncaughtError. (dart:async/zone.dart:1112:29) E/flutter ( 6443): #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) E/flutter ( 6443): #2 _startMicrotas

I am testing using Samsung Galaxy J7 Prime (SM-G610Y) with android version 6.0.1.

babariviere commented 6 years ago

Are you using the function onSmsDelivered?

babariviere commented 6 years ago

I've pushed a fix, this should be good now. Reopen if not

litzbalane2017 commented 6 years ago

Are you using the function onSmsDelivered?

No. I am not using that function.

I've pushed a fix, this should be good now. Reopen if not

I've tested it and still messages are not sent via 2nd sim slot. I am getting the following error messages and incorrect message.onStateChanged saying the SMS was sent.

D/flutter_sms(21885): Sent result: SmsManager.RESULT_ERROR_GENERIC_FAILURE I/flutter (21885): SMS is sent!`

babariviere commented 6 years ago

You have this error because you're second sim card cannot send SMS

litzbalane2017 commented 6 years ago

I see. It seems to just preferring to send with a particular sim card, even if I try to switch the default sim for text. It will find it and send it with sender.sendSms(message, simCard: card.first); even if I put it on either slot 1 or slot 2.

I then tried using other sim cards without the preferred one, the same message appears and now I cannot send on both sender.sendSms(message, simCard: card.first); or sender.sendSms(message, simCard: card.last);:

D/flutter_sms(21885): Sent result: SmsManager.RESULT_ERROR_GENERIC_FAILURE I/flutter (21885): SMS is sent!`

Not sure how this is still happening, since all sim cards work perfectly fine if I do not use a simcard parameter in sender.sendSms(message);

babariviere commented 6 years ago

I can't find where is the issue, if I found how to fix I will ping you