|
| 1 | + |
| 2 | +# Notes |
| 3 | + |
| 4 | +### Android |
| 5 | + |
| 6 | +**Package Information:** |
| 7 | +> minSdkVersion: 26 |
| 8 | +> compileSdkVersion: 34 |
| 9 | +
|
| 10 | +**Gradle:** |
| 11 | +> gradle-wrapper: 8.2.1-all |
| 12 | +
|
| 13 | +**Permissions:** |
| 14 | +* `android.permission.FOREGROUND_SERVICE` |
| 15 | +Required for foreground services on Android 10+ including running foreground services in the background e.g. to capture microphone audio. |
| 16 | + |
| 17 | +* `android.permission.RECORD_AUDIO` |
| 18 | +Grants access to the microphone for audio recording, to be used for voice calls. |
| 19 | + |
| 20 | +* `android.permission.READ_PHONE_STATE` |
| 21 | +Required for reading the phone state, the phone state is the backbone permission for `ConnectionService` integration. It allows checking active calls, placing new calls, and receiving calls and call state updates. It also allows creating a `PhoneAccount` required for placing calls. If not accepted, any and all incoming calls are rejected immediately upon receiving `CallInvite`. |
| 22 | + |
| 23 | +* `android.permission.READ_PHONE_NUMBERS` |
| 24 | +Required for reading phone numbers (e.g. for Telecom App), this is required to create a `PhoneAccount`, see `READ_PHONE_STATE` above. |
| 25 | + |
| 26 | +* `android.permission.CALL_PHONE` |
| 27 | +Required for `ConnectionService` to interact with the `TelecomManager` to place outgoing calls. |
| 28 | + |
| 29 | +#### ConnectionService integration |
| 30 | + There are a few (additional) permissions added to use the [system-managed `ConnectionService`](https://developer.android.com/reference/android/telecom/ConnectionService), several permissions are required to enable this functionality (see example app). These permissions `android.permission.READ_PHONE_STATE`, `android.permission.READ_PHONE_NUMBERS`, `android.permission.RECORD_AUDIO` and `android.permission.CALL_PHONE` have already been added to the package, you do not have to add them. Finally, a [PhoneAccount] is required to interact with the `ConnectionService`, this is discussed in more detail below. |
| 31 | + |
| 32 | + |
| 33 | +#### Phone Account |
| 34 | +Registering of a [PhoneAccount](https://developer.android.com/reference/android/telecom/PhoneAccount)'s are essential to the functionality. This is integrated into the plugin - however it should be noted if the `PhoneAccount` is not registered nor the `Call Account` enabled, the plugin will not function as expected. See [here](https://developer.android.com/reference/android/telecom/PhoneAccount) for more information regarding `PhoneAccount`s. Logging output will indicate whether any permissions are lacking, or missing. |
| 35 | + |
| 36 | +To register a Phone Account, request access to `READ_PHONE_NUMBERS` permission first. |
| 37 | +```dart |
| 38 | +TwilioVoice.instance.requestReadPhoneNumbersPermission(); |
| 39 | +``` |
| 40 | +then, register the `PhoneAccount` |
| 41 | + |
| 42 | +To open the `Call Account` settings, use the following code: |
| 43 | +```dart |
| 44 | + TwilioVoice.instance.openPhoneAccountSettings(); |
| 45 | +``` |
| 46 | + |
| 47 | +alternatively, this could be found in Phone App settings -> Other/Advanced Call Settings -> Calling Accounts -> Twilio Voice (toggle switch) |
| 48 | + |
| 49 | +(if there is a method to programmatically open this, please submit a PR) |
| 50 | + |
| 51 | +### iOS & macOS |
| 52 | + |
| 53 | +If you encounter this error |
| 54 | +> warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.XX, but the range of supported deployment target versions is 10.XY to 13.1.99. (in target 'ABCD' from project 'Pods') |
| 55 | +
|
| 56 | +To resolve this: |
| 57 | +- open XCode |
| 58 | +- browse to your Pods project (left `Project Navigator` drawer, select `Pods` project (there is `Pods` or `Runner`, expand and select `Pods` folder) |
| 59 | +- for each pod with the above issue, select the `pod` > then select the `General` tab > and set `Minimum Deployments` to the value to e.g. `10.15` (or whatever the latest version is that you're using in your main project). |
| 60 | + |
| 61 | +You may also add this to your `Podfile` to ensure you don't do this each time: |
| 62 | +``` |
| 63 | +post_install do |installer| |
| 64 | + installer.pods_project.targets.each do |target| |
| 65 | + flutter_additional_macos_build_settings(target) |
| 66 | +
|
| 67 | + # Add from here |
| 68 | + target.build_configurations.each do |config| |
| 69 | + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.15' # or whatever version you're using |
| 70 | + end |
| 71 | + # to here |
| 72 | +
|
| 73 | + end |
| 74 | +end |
| 75 | +``` |
| 76 | + |
| 77 | +## Limitations |
| 78 | + |
| 79 | +### macOS |
| 80 | + |
| 81 | +Clearly, macOS isn't uppermost in mind when looking at a mobile first platform like Flutter. There are some functionality limitations for the platform/interop such as [UIImage](https://docs.flutter.dev/ui/assets-and-images#loading-ios-images-in-flutter) support and Twilio Voice library support as a whole. Hopefully we'll be seeing these implemented in future. |
0 commit comments