Pregunta

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

¿Fue útil?

Solución

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

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top