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

sms.requestPermission always calls error handler #189

Closed
JeffBerman opened this issue Feb 13, 2019 · 11 comments
Closed

sms.requestPermission always calls error handler #189

JeffBerman opened this issue Feb 13, 2019 · 11 comments

Comments

@JeffBerman
Copy link

JeffBerman commented Feb 13, 2019

Hi, our Cordova app has always used the cordova-sms-plugin and it has worked great (thank you). Due to the Google policy change we have updated our app to have the latest version of the plugin, but we can't get it to work on Android devices.

We do specify intent: 'INTENT' in the options object, and we copied in the sample code with the checkSMSPermission() and requestSMSPermission() functions. However, requestSMSPermission() always logs '[WARN] Permission not accepted' and the SMS is not sent.

When using the native Android messaging app to send SMS on behalf of our Cordova app, are checkSMSPermission() and requestSMSPermission() required? Or are they only needed when trying to send SMS directly from within the Cordova app?

Thanks!

@dbaq
Copy link
Member

dbaq commented Feb 13, 2019

Hey Jeff,

Thanks for reaching out.

When using the native Android messaging app to send SMS on behalf of our Cordova app, are checkSMSPermission() and requestSMSPermission() required? Or are they only needed when trying to send SMS directly from within the Cordova app?

The permission is only required if you sent the SMS with intent:''. If you use intent: 'INTENT', you don't need to request or check the permission.

Have you checked logcat? adb logcat? Also make sure the permission are not in the manifest XML file.

@JeffBerman
Copy link
Author

Awesome, thanks for replying, Didier. I haven't checked logcat. I honestly don't know much about how Android works and am still trying to figure it all out.

After I posted my question I rewrote our code to just directly call sms.send(), and that did work. It brought up the native Android message app with the number and message pre-filled.

Our next struggle is getting the new app approved by the Google Play store. It keeps removing our app saying we don't comply with their SMS policy, and yet there is no SMS privilege specified in the app manifest. Our app store listing even shows "Send SMS messages" under the permissions section, even though it shouldn't be there. Strange.

Anyway, thanks for your help!

@dbaq
Copy link
Member

dbaq commented Feb 14, 2019

Hey Jeff,

Glad you figured it out. Make sure the permission are not in the platforms/android/AndroidManifest.xml file or in platforms/android/android.json.

I'd recommend you to do a search across all your files to look for the permission name SEND_SMS or READ_PHONE_STATE. You should have none before submitting your app for review.

Let me know when you figure it out.

@JeffBerman
Copy link
Author

Hey Didier,

Thanks for the advice! I cleaned the project and then did a build, and verified that READ_PHONE_STATE and SEND_SMS don't appear anywhere in the project. Well, SEND_SMS appears a few times, but only in the actual plugin code and build artifacts.

I uploaded the new APK to Google Play, and it keeps bringing up the "Permissions Declaration Form", as if there is a SEND_SMS permission still declared. The options are "Yes", for which you have to declare why sending SMS messages is a core functionality of your app -- which doesn't apply to us, or "No", which says that our app doesn't meet their SMS permissions policy. I would expect that that form wouldn't even appear if the APK doesn't declare SEND_SMS, though.

Do you have any thoughts on this?

@dbaq
Copy link
Member

dbaq commented Feb 14, 2019

Yop,

... and build artifacts

Which build artifacts are you referring to?

Do you have any thoughts on this?

Not really, sorry. Post the same message on this issue: #183. Maybe someone else had the same issue.

@JeffBerman
Copy link
Author

Which build artifacts are you referring to?

  • platforms\android\app\build\intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\cordova\plugins\sms\Sms.class
  • platforms\android\app\build\intermediates\transforms\dexBuilder\release\18\com\cordova\plugins\sms\Sms.dex
  • platforms\android\app\build\intermediates\transforms\dexMerger\release\0\classes.dex
  • platforms\android\app\src\main\java\com\cordova\plugins\sms\Sms.java

Those are the only hits for SEND_SMS. I'm not too familiar with Cordova, but I think they are benign.

Thanks!

@dbaq
Copy link
Member

dbaq commented Feb 15, 2019

Yep they are benign, just wanted to double check. Please cross post your problem on the other thread and hopefully, someone will be able to help you out.

@dbaq
Copy link
Member

dbaq commented Feb 22, 2019

hey @JeffBerman, any updates?

@JeffBerman
Copy link
Author

Hey @dbaq, thanks for following up. Sorry for not getting back to you sooner, I was out of town.

Yes, it looks like after loading every app release slot with the latest APK, it took over a day for the Google warning message to go away. It has been several days now and the warning message has not reappeared, so I think we're good.

Thanks again for your help!

@dbaq
Copy link
Member

dbaq commented Feb 26, 2019

No worries, I am glad you figured out your problem.

Happy coding!

@MarcWeber
Copy link

MarcWeber commented Jul 23, 2020

I got the exact same problem. But want to use 'intent': '' thus not open the SMS app thus need the permission. The adb logcat didn't reveal anything which was close to permissions.. The failure object is' USER HAS DENIED PERRMISSION', but in settinsg -> SMS I cannot find my cordova app to allow it?

When adding the SEND_SMS to platforms/android/android.json

         { 
              "xml": "<uses-permission android:name=\"android.permission.SEND_SMS\" />",
              "count": 1
            },

I get " platforms/android/app/src/main/res/xml/config.xml:10: error: unbound prefix."

So I think some documentation is missing ?

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

No branches or pull requests

3 participants