Closed alanaasmaa closed 5 years ago
ANSWER_PHONE_CALLS is a Android O and greater API; if your tool chain is set to build for older versions of the API; it is very possible ANSWER_PHONE_CALLS
is not actually a valid item and you are then passing undefined
into the permissions system.
I would highly recommend you use the real value of what ANSWER_PHONE_CALLS
is; so that you make sure you are passing in a permission value...
@NathanaelA I just need to support android 8.0
I double checked that im using SDK version 26. And i assume nativescript cant build for lover SDK whene there is no available.
I tried with the real valua but i just relised that should the real value be a string ?
Because android.permission or something was undefined also.
Edit: i feel stupid. Of course its string..
Yes, it is a string value; and also frequently it is actually under Manifest.android
or Manifest.permissions
Didnt work.
I will try something else later this day.
permissions.requestPermission('android.permission.ANSWER_PHONE_CALLS', 'For answering and ending phone calls')
.then(function() {
console.log(`Woo Hoo, I have the power for ${permissionName}!`);
const TelecomMgr = AndroidApp.context.getSystemService(android.content.Context.TELECOM_SERVICE);
console.log(TelecomMgr.isInCall)
TelecomMgr.prototype.endCall()
})
.catch(function() {
console.log(`Uh oh, no permissions for ${permissionName} - plan B time!`);
});
The code above you tried and it didn't work? Have you tried setting your minSdkVersion also set to 26?
app/app_resources/AndroidManifest.xml
-- This might cause issues if it isn't...
@NathanaelA Yes there is 21 currently.
I'm at Office now so I can't test it after 8 hours.
I actually did try to look for min value but didn't look in this file. I found from build folder some values and they all were 26.
I assume the issue is not with your awesome package. But I keep it open and I will update when I get home.
@NathanaelA
When I'm doing permissions.hasPermission('android.permission.ANSWER_PHONE_CALLS')
It returns true. But for some reason with requestPErmission it resolve promise.
Also im not sure if endCall() is undefined because permission or is there some other reason
I took a Moto G6 for testing which also has Android 8. Does not seem to work there either
try {
console.log(permissions.hasPermission('android.permission.ANSWER_PHONE_CALLS'))
const TelecomMgr = AndroidApp.context.getSystemService(android.content.Context.TELECOM_SERVICE);
console.log(TelecomMgr.isInCall)
TelecomMgr.endCall()
} catch (error) {
console.log(error)
}
JS: true
JS: { [Function: isInCall]
JS: [length]: 0,
JS: [name]: 'isInCall',
JS: [arguments]: null,
JS: [caller]: null,
JS: [prototype]: { [constructor]: [Circular] } }
JS: [TypeError: TelecomMgr.endCall is not a function]
Im loggin isInCall because it ins same class but does not require ANSWER_PHONE_CALLS permission.
I try to get the permission manually. But i assume the issue is elsrwere.
I close this issue as it seems i have permission. I tried with native code. So it seems that the issue is elsewhere.
When you came here from google i have asked from slack => https://nativescriptcommunity.slack.com/archives/C0MMFBJNR/p1537802288000100
Also i will update the result here.
Does not work with this permission.
I'm very new to Nativescript so i might be wrong.
hasPermission method crashed, and requestPermission does nothing.
Using Android 8.0 on OnePlus 3T