dilluns, 20 de gener del 2014

New features of iOS7: iOS now request user consent to use the microphone





You know that iOS request user permission in order to retrieve user location. The same for accessing user contacts, reminders or photos. Now, with iOS 7 access to the microphone is also on that list. Note that if users denies access to the microphone, then the app will not be able to use the microphone.

In order to prompt the user to grant access to the microphone you can use the following code:


// The first time you call this method, the system prompts the user to grant your app access
// to the microphone; any other time you call this method, the system will not prompt the user
// and instead passes the previous value for 'granted'
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
    if (granted) {
        // the user granted permission!
    } else {
        // maybe show a reminder to let the user know that the app has no permission?
    }
}];

Cap comentari:

Publica un comentari a l'entrada