akshaydoshi2 / flutter_sim_data

MIT License
1 stars 1 forks source link

Not able to send sms in Android 13. #2

Open devucs opened 2 days ago

devucs commented 2 days ago

I am able to receive the Sim information however when trying to send SMS with the help of sendSMS method. I am receiving toast "SMS not sent. Something went wrong!"

Tried adding await also since its Future, But still no luck. Also receiving the same toast thrice even though action triggered only one time.

Can you please help me out here?

if (_selectedSimDataModel != null) {
              final jsonObject = {
                'carrierName': _selectedSimDataModel?.carrierName,
                'cardId': _selectedSimDataModel?.cardId,
                'countryCode': _selectedSimDataModel?.countryCode,
                'displayName': _selectedSimDataModel?.displayName,
                'isESIM': _selectedSimDataModel?.isESIM,
                'phoneNumber': _selectedSimDataModel?.phoneNumber,
                'simSlotIndex': _selectedSimDataModel?.simSlotIndex,
                'subscriptionId': _selectedSimDataModel?.subscriptionId
              };

              debugPrint('jsonObject: $jsonObject');
              final key = Utils().generateRandomString(32); // 32-byte key
              final iv = Utils().generateRandomString(16); // 16-byte IV

              // Create the token
              final token =
                  SecurityUtils.createEncryptedToken(jsonObject, key, iv);

              debugPrint('jsonObjectToken: $token');
              try {
                _simDataPlugin.sendSMS(
                  phoneNumber: "+911234567890",
                  message: "D8E8G $token",
                  subId: _selectedSimDataModel!.subscriptionId,
                );
              } on Exception catch (ex) {
                debugPrint(ex.toString());
              }
            }
          },
akshaydoshi2 commented 13 hours ago

Hey @devucs , please confirm the below points to identify the issue: