// Created by test name on 12/13/16.
// Copyright В© 2016 Unisound. All rights reserved.
#import <AVFoundation/AVFoundation.h>
@interface DialogSampleController : UIViewController
@interface DialogSampleController ()
@implementation DialogSampleController
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
- (void) showRequestInfoDialog
if ([[AVAudioSession sharedInstance] recordPermission] == AVAudioSessionRecordPermissionGranted)
if ([[AVAudioSession sharedInstance] recordPermission] == AVAudioSessionRecordPermissionDenied ||
[[NSUserDefaults standardUserDefaults] objectForKey:@"admanLastMicroPermissionNotifyDate"] != nil) {
NSDate *lastNotifyDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"admanLastMicroPermissionNotifyDate"];
NSDateComponents *diff = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:lastNotifyDate toDate:[NSDate new] options:NSCalendarWrapComponents];
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:@"Microphone disabled."
message:@"If you want to control advertising with your voice and even skip it please enable microphone permission in Settings."
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction
style:UIAlertActionStyleDefault
[self presentViewController:alert animated:NO completion:nil];
UIAlertController * infoDialog = [UIAlertController
alertControllerWithTitle:@"Do you want to enable Dialogue Ads?"
message:@"Now you can control advertising with your voice and even skip it. Do you want to try Dialogue Advertising?"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* noButton = [UIAlertAction
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDate *today = [NSDate new];
[defaults setObject:today forKey:@"admanLastMicroPermissionNotifyDate"];
UIAlertAction* yesButton = [UIAlertAction
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL permission) {}];
[infoDialog addAction:noButton];
[infoDialog addAction:yesButton];
[self presentViewController:infoDialog animated:NO completion:nil];