SMS not supported on this platform(Samsung tabs)

  • 1
  • Question
  • Updated 4 years ago
I have built app that has plugin for SMS

It is working fine in most of the devices but samsung tab.
Can someone please suggest me which plugin is to be used?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
What do you want the plugin to do? Why would a hyperlink with href="sms:..." not suffice?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
I want to send sms on button click.
I am using plugin com.cordova.plugins.sms
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Well, if you insist on using a plugin, for whatever reason (you didn't specify), don't use that old, deprecated plugin from the pgb repo. Instead, use the latest version of cordova-sms-plugin from npm
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
First I am using
gap:plugin name="com.cordova.plugins.sms" spec="0.1.2" source="pgb"
Now i have updated
gap:plugin name="cordova-plugin-sms" source="npm"
As suggested below url
cordova-plugin-sms

After updating code showing error sms not defined

I had tried to solve this using below url but not succeed
Tried solutions
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
From the plugin's docs:
The problem is that you need to make sure that you set the target to android-19 or later

Did you?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
Where it is mentioned in Plugin's doc?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
Or How i will implement?
Please send me code.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
My config file is

<?xml version='1.0' encoding='utf-8'?>
<widget id="org.test.pdc" version="1.7.2" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Collection</name>
<description>Application</description>
<author email="" href="">Test</author>
<content src="index.html" />
<preference name='phonegap-version' value='cli-5.1.1' />
<preference name="android-build-tool" value="gradle" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-installLocation" value="auto" />
<preference name="SplashScreenDelay" value="5000" />
<gap:plugin name="org.apache.cordova.battery-status" source="npm"/>
<gap:plugin name="org.apache.cordova.camera" source="npm"/>
<gap:plugin name="org.apache.cordova.media-capture" source="npm"/>
<gap:plugin name="org.apache.cordova.console" source="npm"/>
<gap:plugin name="org.apache.cordova.contacts" source="npm"/>
<gap:plugin name="org.apache.cordova.device" source="npm"/>
<gap:plugin name="org.apache.cordova.device-motion" source="npm"/>
<gap:plugin name="org.apache.cordova.device-orientation" source="npm"/>
<gap:plugin name="org.apache.cordova.dialogs" source="npm"/>
<gap:plugin name="org.apache.cordova.file" source="npm"/>
<gap:plugin name="org.apache.cordova.file-transfer" source="npm"/>
<gap:plugin name="org.apache.cordova.geolocation" source="npm"/>
<gap:plugin name="org.apache.cordova.globalization" source="npm"/>
<gap:plugin name="org.apache.cordova.inappbrowser" source="npm"/>
<gap:plugin name="org.apache.cordova.media" source="npm"/>
<gap:plugin name="org.apache.cordova.network-information" source="npm"/>
<gap:plugin name="org.apache.cordova.splashscreen" source="npm"/>
<gap:plugin name="org.apache.cordova.vibration" source="npm"/>
<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.0" />
<gap:plugin name="cordova-plugin-sms" source="npm" />

<icon src="icon.png" />
<icon gap:platform="android" gap:qualifier="ldpi" src="res/icon/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="res/icon/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="res/icon/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />

<gap:splash src="splash.png" />
<gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />

<access origin="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
</widget>

Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Test Account
Since this appears to be your first posting, please answer the following questions.
- is this your first hybrid mobile app?
- are you using phonegap desktop app?
- Are you using CLI, Build or SDK? Please do not assume the answer. Please read the link.

Thanks
Jesse
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
- is this your first hybrid mobile app? - Yes
- are you using phonegap desktop app? - No
- Are you using CLI, Build or SDK? Please do not assume the answer. Please read the link. - Build
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
It's working in Samsung tab 2 but not working in Samsung tab 3 and 4.
Can anyone please provide solution?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. You have this:
<plugin name="cordova-plugin-whitelist" version="1" />
That version doesn't exist at npm. Remove the version attribute.

2. You have this
<allow-intent href="sms:*" />
Why did you include that?

3. You are using all old, deprecated plugins, or at least their names.
Be aware that the plugins at npm are named differently (usually something like 'cordova-plugin-....', but not always). Find the correct names and replace.

4. On your test in Tab3/Tab4: do you receive any error messages? If not, which part of your code is executed, and where does it fail?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
In Tab 3 and Tab 4, It's showing error SMS not supported on this platform

I have found it's break due to FEATURE_TELEPHONY not supported on these devices.

ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)

Can you please suggest me any other plugin, which doesn't use FEATURE_TELEPHONY ** feature.

Thanks
Ankit
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
How do you plan to send SMS without a phone connection?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
No, I want with phone connection(Default SMS functionality).
I am not using any third party api.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
But why do you insist on sending SMS using devices that don't have such phone connection on board, then?
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
Those tabs are having phone connections and SIM inserted as well. We can send the SMS through default messaging app though the PhoneGap app we create gives us the error mentioned above.

The point here is that the plugin for SMS checks for FEATURE_TELEPHONY feature and Samsung tabs somehow gives false for this even when they have the features of phone.

So we need a plugin that doesn't check for this feature.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
You may want to try any of these:
http://cordova.apache.org/plugins/?q=sms
Photo of Test Account

Test Account

  • 12 Posts
  • 0 Reply Likes
Yes,
I have tried all plugins.
My requirement is SMS send in background, It's should not open Native SMS app.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Have you considered setting up an SMS Gateway on your server (or the usage of an SMS online service)?
That would enable you to send the data from your app per Ajax/XHR to the server and send the SMS from there. Such option would also enable tablets without SIM card to send SMS. And of course, the native SMS app is not activated.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Petra,
I'm on a desktop for the next few evenings.
I need to get some talks done. and some blog posts done.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Fine, Jesse. Thanks for letting me know.

Meanwhile, I will try and save the World all by myself. A terrible job, but someone has to do it.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
TestAccount:
Meanwhile, you have ignored a couple of steps from this thread:

- set targetSDK to 19 or higher
- why is an intent rule for 'sms:*' included?

Finally another suggestion: since you found the statement in the plugin's source, which causes the issue, you could consider forking the plugin, removing the statement and uploading it as a separate plugin.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Test Account

The following example code works for SMS. I did not test for background operations. if you are using Android 6.x, you may need an exception.

CODE: https://github.com/jessemonroy650/3rdParty-send-SMS-Example

Android 6 and Doze

I will return in 24 hours.

Best of Luck
Jesse