Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20544] Align permission methods Ti.Media.AudioRecorder with the others

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2017-05-06T14:35:21.000+0000
Affected Version/sRelease 5.2.2
Fix Version/sRelease 6.1.0
ComponentsAndroid, iOS, Windows
Labelsandroid, merge-6.1.0
ReporterFokke Zandbergen
AssigneeVijay Singh
Created2016-03-10T12:32:34.000+0000
Updated2017-05-11T00:02:45.000+0000

Description

To request permission for using the currently iOS and Windows only Ti.Media.AudioRecorder you need [Ti.Media.requestAuthorization()](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-requestAuthorization) To achieve parity and consistency with other new permission APIs we need: * To deprecate Ti.Media.requestAuthorization() * To add Ti.Media.requestRecorderPermission() for iOS and Windows While we're at it we should also resolve TIMOB-1028 to bring Ti.Media.AudioRecorder to Android Reported on SO: http://stackoverflow.com/questions/35890378/titanium-studio-audio-recording-request-permission-on-android-6-0

Comments

  1. Fokke Zandbergen 2016-04-19

    This needs more priority: * http://stackoverflow.com/questions/36683249/android-6-0-audio-permissions-and-titanium-jar-in-5-2-2ga * http://stackoverflow.com/questions/35890378/how-to-request-run-time-recording-permission-on-android-6-0
  2. Ashraf Abu 2016-04-27

    With TIMOB-20320 merged into 5.4.0, you can now do this:-
       var audioPermission = "android.permission.RECORD_AUDIO";
       var hasAudioPerm = Ti.Android.hasPermission(audioPermission);
       var permissionsToRequest = [];
       if (!hasAudioPerm) {
           permissionsToRequest.push(audioPermission);
       } 
       if (permissionsToRequest.length > 0) {
           Ti.Android.requestPermissions(permissionsToRequest, function(e) {
               if (e.success) {
                   Ti.API.info("SUCCESS");
               } else {
                   Ti.API.info("ERROR: " + e.error);
               }
           });
       }
       
    That would give you RECORD_AUDIO permission. That aside, from my understanding based on this doc, http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.AudioRecorder is not supported/available in Android. Am I missing something? [~fokkezb]
  3. Fokke Zandbergen 2016-05-05

    We should implement Ti.Media.AudioRecorder for Android first and then align the permission methods with the other APIs TIMOB-1028
  4. Ashraf Abu 2016-05-13

    [~rramirez] This would allow you to get the other permissions in 5.4.0. If everything else is okay, I would think this ticket does not require any more action done on it. Let me know if it suffices.
       
       var audioPermission = "android.permission.RECORD_AUDIO";
       var hasAudioPerm = Ti.Android.hasPermission(audioPermission);
       
       var storagePermission = "android.permission.READ_EXTERNAL_STORAGE";
       var hasStoragePerm = Ti.Android.hasPermission(storagePermission);
       
       var permissionsToRequest = [];
       if (!hasAudioPerm) {
           permissionsToRequest.push(audioPermission);
       } 
       if (!hasStoragePerm) {
           permissionsToRequest.push(storagePermission);
       } 
       if (permissionsToRequest.length > 0) {
           Ti.Android.requestPermissions(permissionsToRequest, function(e) {
               if (e.success) {
                   Ti.API.info("SUCCESS");
               } else {
                   Ti.API.info("ERROR: " + e.error);
               }
           });
       }
       
  5. Gary Mathews 2016-12-28

    titanium_mobile_windows: https://github.com/appcelerator/titanium_mobile_windows/pull/909 Merged!
  6. Chee Kiat Ng 2016-12-29

    Looks like we still need iOS to be aligned here. [~vijaysingh]
  7. Vijay Singh 2016-12-29

    IN iOS I can see - Ti.Media.requestAuthorization() is deprecated and new api Ti.Media. requestAudioPermissions() introduced in "5.1.0" .
  8. Chee Kiat Ng 2016-12-29

    Right but in this scenario i think we wanted requestRecorderPermissions().
  9. Vijay Singh 2017-01-23

    PR (for iOS) : https://github.com/appcelerator/titanium_mobile/pull/8767 Test code -
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var btn = Ti.UI.createButton({
           title: 'Trigger'
       });
       
       btn.addEventListener('click', function() {
           Ti.Media.requestAudioRecorderPermissions(function(e){
               if (e.success) {
                   Ti.API.info('permission granted');
               }
               else {
                   console.error(e);
               }
       
           });
       });
       
       win.add(btn);
       win.open();
       
  10. Hans Knöchel 2017-01-23

    Some issue that appear in the iOS PR but will other effect other platforms: - We use the plural when requesting permissions (e.g. requestLocationPermissions, requestCalendarPermissions and requestContactsPermissions), but in this case it's singular - The method is called requestRecorderPermission, but it should rather be recordAudioRecorderPermissions to avoid API confusions - There is still no Android and Windows implementation. We should use this ticket and PR to align that platform as well So question: [~gmathews] Looking at the merge-date of your Windows PR, it should not be included in any SDK so far. Can you still rename it without causing problems? I don't see docs-updates, so we might want to add those as well.
  11. Kota Iguchi 2017-03-24

    [~hansknoechel], {quote} The method is called requestRecorderPermission, but it should rather be recordAudioRecorderPermissions to avoid API confusions {quote} requestAudioRecorderPermissions, right? (I saw your comment on [PR 8767](https://github.com/appcelerator/titanium_mobile/pull/8767)) That sounds good to me, pushed https://github.com/appcelerator/titanium_mobile_windows/pull/965
  12. Hans Knöchel 2017-03-24

    Thanks Kota, looks good! Waiting for [~vijaysingh] to do the iOS change then, and Android of course.
  13. Vijay Singh 2017-03-27

    iOS changes done.
  14. Vijay Singh 2017-04-12

    [~hansknoechel] Backported PR(6_1_X): https://github.com/appcelerator/titanium_mobile/pull/8955
  15. Samir Mohammed 2017-05-05

    Verified on Windows using SDK 6.2.0.v20170505081953 and 6.1.0.v20170504175418
  16. Samir Mohammed 2017-05-11

    Verified on Titanium SDK: 6.2.0.v20170510084833 and 6.1.0.v20170509170935. Windows was verified earlier on SDK 6.2.0.v20170505081953 and 6.1.0.v20170504175418. Test and other information can be found at: 6_1_X (Windows): https://github.com/appcelerator/titanium_mobile_windows/pull/979 6_1_X(iOS): https://github.com/appcelerator/titanium_mobile/pull/8955 Master(Windows): https://github.com/appcelerator/titanium_mobile_windows/pull/965 Master(iOS): https://github.com/appcelerator/titanium_mobile/pull/8767

JSON Source