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-14396]iOS : Audio Session Privacy stuff for iOS 7 #4635

Merged
merged 1 commit into from
Aug 30, 2013
Merged
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
36 changes: 36 additions & 0 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@
static NSDictionary* TI_itemProperties;
static NSDictionary* TI_filterableItemProperties;

#pragma mark - Backwards compatibility for pre-iOS 7.0

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0

@protocol AVAudioSessionIOS7Support <NSObject>
@optional
- (void)requestRecordPermission:(PermissionBlock)response;
typedef void (^PermissionBlock)(BOOL granted)
@end

#endif

@implementation MediaModule
@synthesize popoverView;

Expand Down Expand Up @@ -1460,6 +1472,30 @@ - (void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker_

#pragma mark Microphone support

#pragma Microphone iOS 7 privacy control

-(void) requestAuthorization:(id)args
{
ENSURE_SINGLE_ARG(args, KrollCallback);
KrollCallback * callback = args;
if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]) {
TiThreadPerformOnMainThread(^(){
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted){
KrollEvent * invocationEvent = [[KrollEvent alloc] initWithCallback:callback
eventObject:[TiUtils dictionaryWithCode:(granted ? 0 : 1) message:nil]
thisObject:self];
[[callback context] enqueue:invocationEvent];
}];
}, NO);
} else {
NSDictionary * propertiesDict = [TiUtils dictionaryWithCode:0 message:nil];
NSArray * invocationArray = [[NSArray alloc] initWithObjects:&propertiesDict count:1];
[callback call:invocationArray thisObject:self];
[invocationArray release];
return;
}
}

-(void)startMicrophoneMonitor:(id)args
{
[[SCListener sharedListener] listen];
Expand Down