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

[TIMOB-20544](6_1_X):Align permission methods Ti.Media.AudioRecorder with the others #8955

Merged
merged 3 commits into from
May 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 43 additions & 1 deletion apidoc/Titanium/Media/Media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ methods:
platforms: [iphone, ipad]
deprecated:
since: "5.1.0"
notes: Use <Titanium.Media.requestAudioPermissions> instead.
notes: Use <Titanium.Media.requestAudioRecorderPermissions> instead.
since: 3.1.3
parameters:
- name: callback
Expand All @@ -386,8 +386,28 @@ methods:
returns:
type: Boolean
platforms: [iphone, ipad]
deprecated:
since: "6.1.0"
notes: Use <Titanium.Media.hasAudioRecorderPermissions> instead.
since: "6.0.0"

- name: hasAudioRecorderPermissions
summary: Returns `true` if the app has audio permissions.
description: |
On iOS 7.0, recording audio requires explicit permission from the user. After the user
grants or denies permission, the system remembers the choice for future use in the same app.
If permission is not granted, or if the user has not yet responded to the permission prompt,
any audio recording sessions record only silence.

In addition, Apple introduced the Info.plist key `NSMicrophoneUsageDescription` that is used to display an
own description while authorizing microphone permissions. In iOS 10, this key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.
returns:
type: Boolean
platforms: [iphone, ipad]
since: "6.1.0"

- name: requestAudioPermissions
summary: Request the user's permission for audio recording.
description: |
Expand All @@ -401,12 +421,34 @@ methods:
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.
platforms: [iphone, ipad]
deprecated:
since: "6.1.0"
notes: Use <Titanium.Media.requestAudioRecorderPermissions> instead.
since: 5.1.0
parameters:
- name: callback
summary: Callback function to execute when the users responds to the authorization alert.
type: Callback<MediaAuthorizationResponse>

- name: requestAudioRecorderPermissions
summary: Request the user's permission for audio recording.
description: |
On iOS 7.0, recording audio requires explicit permission from the user. After the user
grants or denies permission, the system remembers the choice for future use in the same app.
If permission is not granted, or if the user has not yet responded to the permission prompt,
any audio recording sessions record only silence.

In addition, Apple introduced the Info.plist key `NSMicrophoneUsageDescription` that is used to display an
own description while authorizing microphone permissions. In iOS 10, this key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.
platforms: [iphone, ipad]
since: 6.1.0
parameters:
- name: callback
summary: Callback function to execute when the users responds to the authorization alert.
type: Callback<MediaAuthorizationResponse>

events:
- name: cameraready
summary: Fires when the camera overlay is ready to take pictures.
Expand Down
20 changes: 18 additions & 2 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,21 @@ -(void)setOverrideAudioRoute:(NSNumber*)mode
#ifdef USE_TI_MEDIAREQUESTAUTHORIZATION
-(void)requestAuthorization:(id)args
{
DEPRECATED_REPLACED(@"Media.requestAuthorization", @"5.1.0", @"Media.requestAudioPermissions");
[self requestAudioPermissions:args];
DEPRECATED_REPLACED(@"Media.requestAudioPermissions", @"5.1.0", @"Media.requestAudioRecorderPermissions");
[self requestAudioRecorderPermissions:args];
}
#endif

#ifdef USE_TI_MEDIAHASAUDIOPERMISSIONS
-(id)hasAudioPermissions:(id)unused
{
DEPRECATED_REPLACED(@"Media.hasAudioPermissions", @"6.1.0", @"Media.hasAudioRecorderPermissions");
return [self hasAudioRecorderPermissions:unused];
}
#endif

#if defined(USE_TI_MEDIAHASAUDIORECORDERPERMISSIONS) || defined(USE_TI_MEDIAHASAUDIOPERMISSIONS)
-(id)hasAudioRecorderPermissions:(id)unused
{
NSString *microphonePermission = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSMicrophoneUsageDescription"];

Expand All @@ -593,6 +601,14 @@ -(id)hasAudioPermissions:(id)unused

#ifdef USE_TI_MEDIAREQUESTAUDIOPERMISSIONS
-(void)requestAudioPermissions:(id)args
{
DEPRECATED_REPLACED(@"Media.requestAudioPermissions", @"6.1.0", @"Media.requestAudioRecorderPermissions");
[self requestAudioRecorderPermissions:args];
}
#endif

#if defined(USE_TI_MEDIAREQUESTAUDIORECORDERPERMISSIONS) || defined(USE_TI_MEDIAREQUESTAUDIOPERMISSIONS) || defined(USE_TI_MEDIAREQUESTAUTHORIZATION)
-(void)requestAudioRecorderPermissions:(id)args
{
ENSURE_SINGLE_ARG(args, KrollCallback);
KrollCallback * callback = args;
Expand Down
2 changes: 2 additions & 0 deletions iphone/Classes/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
#define USE_TI_MEDIAHIDEMUSICLIBRARY
#define USE_TI_MEDIAQUERYMUSICLIBRARY
#define USE_TI_MEDIAREQUESTAUDIOPERMISSIONS
#define USE_TI_MEDIAREQUESTAUDIORECORDERPERMISSIONS
#define USE_TI_MEDIAHASAUDIORECORDERPERMISSIONS
#define USE_TI_MEDIAHASAUDIOPERMISSIONS
#define USE_TI_MEDIAREQUESTAUTHORIZATION
#define USE_TI_MEDIAHASMUSICLIBRARYPERMISSIONS
Expand Down