jefflinwood / twilio_client_phonegap

Phonegap plugins for the Twilio Client iOS and Android SDKs
MIT License
59 stars 53 forks source link

Twilio Plugin for twilio android sdk 1.2.13 #66

Closed fedxgibson closed 7 years ago

fedxgibson commented 7 years ago

Hi! I think we should make the plugin available to a more recent version of twilio android sdk. This is because older version uses a vulnerable version of openssl.

The plugin breaks if I replace sdk to a newer version > 1.2.10

jefflinwood commented 7 years ago

That sounds reasonable to me.

I'll take a look at the latest version of the SDK, but I do know that the packaging has changed from JAR to AAR. I should also be able to set the plugin up to use the framework tag to download the AAR file from jcenter.

fedxgibson commented 7 years ago

Thanks for the quick answer! I appreciate the help. I am trying to upload to the play store, but google does not allow me because of that openssl vulnerability.

jefflinwood commented 7 years ago

No problem - so far I've had to upgrade my cordova version, cordova android plugin, update the plugin.xml, and add a build-extras.gradle, but I think I'm on the right path!

jefflinwood commented 7 years ago

Ok, just updated the plugin on master - please try this out, test it to see if you run into anything I didn't. You will definitely need to update your Cordova Android platform to 5.2.1.

And if it works for you, please close the issue - thanks!

fedxgibson commented 7 years ago

I've done all the steps, unfortunately I can't do any phone call ( Javascript side is good, because with older version of plugin was working). So the problem is that i am not receiving any callback from the plugin. Have you tried in an example? My libs folder is now empty, i think it is ok, if now the files are aar.

fedxgibson commented 7 years ago

I took a look at gradle aar folder, and it seems the twilio client has been downloaded, but yes, I am still not receiving response from the plugin.

jefflinwood commented 7 years ago

Hi,

I have tried out my PhoneGap example, and it appears to work fine. That said - are you getting any errors in the logcat output for the Android app?

Thanks!

fedxgibson commented 7 years ago

Indeed! I found this error on logcat:

08-16 13:08:40.451  8331  8425 E TCPlugin: Error Initializing Twilio: Runtime access to android.permission.RECORD_AUDIO is not enabled. You must request this permission at runtime with targetSDKVersion 23 or higher.
08-16 13:08:40.451  8331  8425 E TCPlugin: java.lang.RuntimeException: Runtime access to android.permission.RECORD_AUDIO is not enabled. You must request this permission at runtime with targetSDKVersion 23 or higher.
08-16 13:08:40.451  8331  8425 E TCPlugin:  at com.twilio.client.impl.TwilioImpl.initialize(TwilioImpl.java:143)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at com.twilio.client.Twilio.initialize(Twilio.java:37)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at com.phonegap.plugins.twilioclient.TCPlugin.initTwilio(TCPlugin.java:158)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at com.phonegap.plugins.twilioclient.TCPlugin.execute(TCPlugin.java:104)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at org.apache.cordova.PluginManager.exec(PluginManager.java:133)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at android.os.Handler.dispatchMessage(Handler.java:102)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at android.os.Looper.loop(Looper.java:148)
08-16 13:08:40.451  8331  8425 E TCPlugin:  at android.os.HandlerThread.run(HandlerThread.java:61)

I think it's just a matter of permission. I will try to solve it, but dont know exactly how. Thanks!

fedxgibson commented 7 years ago

I tried to downgrade android sdk from 23 to 22, but it was pointless. I didnt receive any error, but I get offline callback immediately.

fedxgibson commented 7 years ago

In line 211 in TCPlugin, i get OFFLINE when calling mDevice.getState(). Do you know what can be causing this?

fedxgibson commented 7 years ago

Well, researching a little bit, I came across that we should grant permission to our app for recording audio in runtime. This is new SDK 23 new feature.

jefflinwood commented 7 years ago

Hi,

Yes - that's an improvement that needs to be added to the app - can you downgrade the target SDK version to 22 for now? The app is not compatible with 23 yet.

Thanks! Jeff

jefflinwood commented 7 years ago

Hi, I just updated the plugin to 1.0.7 with support for runtime permissions for Android Marshmallow. Try it out!

fedxgibson commented 7 years ago

Thanks Jeff! The update works as expected.

However, what's happening to me is that I receive online callback. Do you know what can be causing this?

It works fine with the older plugin/sdk.

jefflinwood commented 7 years ago

Hi,

Do you mean that you don't get a callback to show that the device is ready?

fedxgibson commented 7 years ago

No, I do get a callback, but it is always "offline" callback. Which is weird, because as I said, with the old plugin it all works fine. May be something with the sdk and backend.

jefflinwood commented 7 years ago

So I saw something similar with another developer's project where they got something similar if they only had outgoing capability on the token, and not incoming.

fedxgibson commented 7 years ago

Oh, yes, I see. It may have something to do with that. My app allows only outgoing. I try to change that. Thank you very much!

jefflinwood commented 7 years ago

Try it out, and let me know - it may be a bug with the plugin somewhere, or it may be coming from the SDK.

fedxgibson commented 7 years ago

Hey! So at the end, My solution was a mixture of two things. First I add an incoming capability to the token. Then I increased the time the thread sleeps to 5 seconds, before it checks device status.

Thanks for the help!

jefflinwood commented 7 years ago

Glad to hear it!