Testing recording permission issue - avaudiosession

The Apple documentation for AVAudioSession Class Reference displays the following about the "requestRecordPermission:" method:
…… This method always returns immediately: if the user has previously
granted or denied recording permission, it executes the block when
called; otherwise, it displays an alert and executes the block only
after the user has responded to the alert.
That is clear,but my problem is this: How can I get back (for testing purposes) to the situation where the user has not yet granted or denied recording permission? I tried to completely remove the app from the device but it did not work.

You have to reset location and privacy.
Settings -> General -> Reset -> Reset Location & Privacy

Related

App Tracking Transparency reset after user choice

I've just implemented the ATT request in my applications. It appears at the app first opening but I would like to show it again if the user wants to change his preferences from the app settings (internal).
I tried to call the requestTrackingAuthorization method again but it enters immediately to the completion handler. Is there a way to reset the status?

iOS 13 check for provisional authorization status of CLLocationManager

As per the WWDC video, https://developer.apple.com/videos/play/wwdc2019/705/, when you ask for "AlwaysAuthorization" permission you will see only "When In Use, Once and Don't allow". Even if you tap on "When In Use", the delegate call back will come back as kCLAuthorizationStatusAuthorizedAlways. This is working as expected. But is there a way to find out that the request is still provisional or actually-always-allow?
There is no enum associated to this permission. The only allowed enums are:
kCLAuthorizationStatusNotDetermined, kCLAuthorizationStatusDenied, kCLAuthorizationStatusAuthorizedAlways, kCLAuthorizationStatusAuthorizedWhenInUse
Because I want to show an alert as soon as user grants the "While In Use" permission, to tell them that the app will only work if you provide "Always Allow" via system preferences and I can navigate them to the system settings page of my app via a tap, just like how Zenly is doing it: https://www.macrumors.com/2019/08/16/app-developers-tracking-restrictions-ios-13/
You can check if you're getting location updates in the background for more than 10 seconds after the application gets in the background. If yes, then you have the permanent Allow Always. If not, then you have the provisional Allow Always (or any other authorization that you can check explicitly).

Not authorized, skipping filter predicate application

Upon launch on an iOS10 device, I get the following output:
[MC] Reading from public effective user settings.
[SDKPlayback] MPMusicPlayerController] MPMusicPlayerController: Server is not running, deferring check-in
[SDKLibrary] Not authorized, skipping filter predicate application
The app plays music from the user's library and therefore must ask permission, so I have updated info.plist with the required key strings for NSAppleMusicUsageDescription but the app crashes as soon as the predicate is called. When the app is stopped and the launch screen disappears, the permission window is finally displayed. If I tap allow, subsequent launches will work just fine.
My question is: Does the "server not running" error have anything to do with the permissions window not being shown? If so, how do I start it?
So, the way an MPMusicPlayerController works is:
You have to have the key in the Info.plist, as you already know.
In your code, check authorization with MPMediaLibrary.authorizationStatus.
If you don't have authorization, you request authorization using MPMediaLibrary.requestAuthorization. You cannot proceed until you have authorization. Be careful because the call is asynchronous and the completion is called on a background thread.
Now you make an MPMediaItemCollection and call setQueue(with:) and then play.

Handling cancel of the location services alert

I do have a situation where I need to get current location of iPhone 5 running iOS8. When the location services is off, the default location service alert open up. This alert has 'Cancel' and 'Settings' button. Please find below the screenshot of the alert.
I need to handle the situation when user pressed cancel on the alert. I can handle it when I override the alert. But that alert isn't working for me, as settings of that custom alert takes me to the app level location settings and not device level location settings.
Set the delegate for your CLLocationManager and implement the delegate's method
- locationManager:didChangeAuthorizationStatus:
This method is called whenever the application’s ability to use location services changes. Changes can occur because the user allowed or denied the use of location services for your application or for the system as a whole.
If the authorization status is already known when you call the requestWhenInUseAuthorization or requestAlwaysAuthorization method, the location manager does not report the current authorization status to this method. The location manager only reports changes to the authorization status. For example, it calls this method when the status changes from kCLAuthorizationStatusNotDetermined to kCLAuthorizationStatusAuthorizedWhenInUse.
Link to Apple doc

iOS MapKit not asking for location permissions

It seems that once the user has denied the application permission to locate her on the map, any subsequent call to [locationManager startUpdatingLocation] will fail, but will not automatically prompt the user to set the correct permission in the settings as the iPhone map app does.
Is this behavior intended on iOS6, or is there a way to force MapKit to ask the user again for permission to use her location?
This behavior is intended. Once the user denied the permission then you can't ask it each time your app starts, if it do it'll be very annoying to user.
If user wants to give permission later, he need to go to settings app and set the necessary permission.
It's same for all type of permissions like location service, push notification, contact permission, photolibrary etc.
You should use the delegate method locationManager:didFailWithError: and look for a kCLErrorDenied.

Resources