2

I need to create a custom ui for mic permission, is there a way to do it.

below is code code how permission block works.. it seems difficult with this call? App Shazam is doing it.

[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted){
if (granted) {
    NSLog(@"granted");
} else {
    NSLog(@"denied");
}}];

Shazam Permission

Cœur
  • 37,241
  • 25
  • 195
  • 267
shavik
  • 75
  • 1
  • 10
  • Well this would get called after permission has been granted or denied, because the permission to use the mic is an Apple requirement it will use the one Apple has made, this is no way around this. If they allowed developers to change it that developer could circumvent the whole process of getting permission so Apple don't allow you to change the permissions UI. Also as a side note, cocoa is Mac cocoa-touch is iphone so I have edited your tags. Sorry to say but I do think you are out of look. – Popeye May 15 '14 at 07:25
  • I too think so but app shazam seems to use custom UI. – shavik May 15 '14 at 07:29
  • 1
    Please can you share an image of the actual interface they use. – Popeye May 15 '14 at 07:30
  • 1
    Isn't it the case that shazam present the system dialogue once you tap "OK"? – Felix Lamouroux May 15 '14 at 07:42
  • and if i say don't allow it pops up alert and this attached UI remains there to ask permission..and by the iOS standard it should disappeared and after that permission can only be set by Settings app. – shavik May 15 '14 at 07:46
  • @shavik I have just intalled Shazam and I got the standard iOS Permissions popup after this page appeared, so they have just made an extra step for the user, which in my opinion isn't user friendly. SO they aren't breaching Apple rules as they still have the iOS standard permissions alert there. – Popeye May 15 '14 at 08:35

2 Answers2

7

I am not aware of any way that you can circumvent the UIAlertViews presented by Apple that ask the user for permissions. What you can do however is this:

  • Present a view explaining in greater detail why you need the specific permission. With two buttons as Shazam does. And tell the user the user that tapping OK will present an alert to confirm.
  • If user taps ok, trigger some action (e.g. location) that requires the user's permission or use the system provided way of asking for permission (e.g. mic).
  • If the user taps "don't allow" you can still in the future present the interface again. With more explanation.

This approach is better than to always use the system's permission dialogue right away, as this can usually only be denied once from within the app. Using a custom view before the alert view allows you to ask more often.

We have also published a framework to help you with that: https://github.com/iosphere/ISHPermissionKit

Felix Lamouroux
  • 7,414
  • 29
  • 46
  • what you are saying is correct.. but the way shazam is doing it seems breach of iOS standards.. as if i say "Ok" it doesn't ask me the standard popup to ask permission(Mic permission set to true directly).. and if i say "don't allow" doesn't set the permission to false. – shavik May 15 '14 at 08:03
  • 2
    I just installed and ran Shazam on a device that had never had it installed. After I clicked "OK" on the screen in your screenshot it displayed the standard iOS "Shazam would like to access the microphone..." dialog – Paulw11 May 15 '14 at 08:24
  • i got your point. Thats the custom UI they alway shows when you reinstall it.. its set the first time you say yes. on further installs device remembers the previous permissions until you reset device permissions... thanks. – shavik May 15 '14 at 08:27
  • 3
    Actually Shazam presents the popup after you clicked on OK. If you didn't see it when you tried it's because you didn't reset your privacy autorizations. Also they don't ask for any autorization when you click "Don't allow" so that next time you install it it will be able to ask again for permissions. *edit : Oops didn't see intermediate answers. – Fantattitude May 15 '14 at 08:36
  • 1
    Sorry for the shameless plug, but we just published a framework to make things easier: https://github.com/iosphere/ISHPermissionKit – Felix Lamouroux Jun 30 '14 at 17:25
1

For iOS >= 7.0

in you app.plist add this key: NSMicrophoneUsageDescription and your desired customized prompt. More details here: https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1

TonyMkenu
  • 7,597
  • 3
  • 27
  • 49