07/09/2018, 15:55

App crash trên iOS 10 vì lỗi privacy description

Nếu app của bạn có sử dụng các thông tin liên quan đến user như là Camera hay Photo Library,... thì khi user sử dụng trên iOS 10, khả năng là app sẽ bị crash. Trong crash log sẽ có đoạn nội dung kiểu như này: Termination Reason: TCC, This app has crashed because it attempted to access ...

Nếu app của bạn có sử dụng các thông tin liên quan đến user như là Camera hay Photo Library,... thì khi user sử dụng trên iOS 10, khả năng là app sẽ bị crash. Trong crash log sẽ có đoạn nội dung kiểu như này:

Termination Reason: TCC, This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

Nguyên nhân là vì từ iOS 10, Apple yêu cầu các developer phải trình bày rõ ràng lý do sử dụng thông tin cá nhân từ thiết bị của user, các thông tin bao gồm: Contacts, Calendar, Reminders, Photos, Bluetooth Sharing, Microphone, Camera, Location, Health, HomeKit, Media Library, Motion, CallKit, Speech Recognition, SiriKit, TV Provider.

Request access to sensitive user or device data, which is protected by the iOS system authorization settings, at the time your app needs the data. You must supply a purpose string (sometimes called a usage description string) in your app’s Info.plist file explaining why your app needs the data or resource you are attempting to access. Data protected by iOS system authorization settings includes location, contacts, calendar events, reminders, photos, media, and many other types as well; see Table 1-2. Provide reasonable fallback behavior in situations where the user does not grant access to the requested data.

Nguồn: Apple Developer Guide - Expected App behaviours

Và để trình bày lý do thì chúng ta có thể thêm vào trong file Info.plist các key mới có nội dung "Privacy - ..."

alt text

Sau khi thêm thông tin privacy vào thì app sẽ hiển thị những thông tin đó khi cần truy xuất đến thông tin của user, ví dụ như hình sau:

Vâng, Apple luôn nổi tiếng với phong cách chơi cứng của mình, hoặc là lên phường trình bày, hoặc là crash, anh cho chú chọn :joy:

0