iOS permission Alerts - removing or suppressing

后端 未结 2 497
长情又很酷
长情又很酷 2020-12-05 11:56

I have a simple app running on ios simulator which will (at some point in the app), prompt the user to authorize the following:

  1. Location setting
  2. Addre
2条回答
  •  广开言路
    2020-12-05 12:25

    There's some discussion here on this topic. I'll quote the relevant portion for posterity:

    For CoreLocation, you can just call the following private method at some point before your first use:

    [CLLocationManager setAuthorizationStatus:YES 
                          forBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]
    

    Privacy alerts for contacts, photos and the calendar are handled differently. These can be set via TCCAccessSetForBundle from TCC.framework, but this function is not callable from within the same app whose privacy settings you're attempting to modify AFAICT.

    Instead, you can just sign your app with these entitlements:

    
    
    
    
        com.apple.private.tcc.allow.overridable
        
            kTCCServiceAddressBook
            kTCCServiceCalendar
            kTCCServicePhotos
        
    
    
    

    To hide your app from the Simulator's Privacy Settings screens, replace com.apple.private.tcc.allow.overridable with com.apple.private.tcc.allow.

    You probably don't want to include these entitlements in your AppStore build.

    (Make sure to take this stuff out when you submit your app - or only include it in your debug target - because it won't pass app review.)

提交回复
热议问题