Application Would You Like to Use Your Current Location! using ALAssetsLibrary - ios

My application only gets image and it's metadata from ios device using ALAssetsLibrary.
When application starts loading images list ios warning is shown..
"Application" Would Like to Use Your Current Location.
This allows access to location information in photos and videos.
Is there way to fix program code in such way that this warning not to be shown? (not by using Setting->General....)
I think user doesn't understand why application during picking the image asks about location.

If you need the metadata info, using assetslibrary is your only option. Using Alassetslibrary means that the user grants permission to location services. The simple reason for that is that the photos metadata might contain location/gps data.
Cheers,
Hendrik

UPDATED: It will not request access permission in iOS 6. You can check the client's [[UIDevice currentDevice]systemVersion] while using ALAssetsLibrary.

Related

Single Image picker in Flutter on iOS without permission

According to those SO questions: UIImagePickerController not asking for permission and No permission to pick a photo from the photo library
If you want to select one image on iOS, you don't have to ask for permission to do it as the app doesn't actually access the gallery.
However, I can't find a way of doing it Flutter. Packages like ImagePicker always ask for permission.
Has anyone succeeded in picking an image in Flutter on iOS without asking for permission?
From Apple documentation:
PHPickerViewController is a new picker that replaces UIImagePickerController. Its user interface matches that of the Photos app, supports search and multiple selection of photos and videos, and provides fluid zooming of content. Because the system manages its life cycle in a separate process, it’s private by default. The user doesn’t need to explicitly authorize your app to select photos, which results in a simpler and more streamlined user experience.
This library uses PHPickerViewController as seen here
The old UIImagePickerController allowed it on older iOS'es, but it has been deprecated, since iOS 14.
The Flutter ImagePicker plugin uses the PHPicker in the iOS code, as I checked for their code on Github, and it allows you to pick an image from the user without requesting permissions. I recommend highly to use that plugin.
Try file_picker it should work for you as it supports all the platform including IOS and Mac supporting various types of file type, you can specify your custom file types also limiting your file selections as well as you can pick files from cloud (GDrive, Dropbox, iCloud)...
First of all add the latest file_picker as a dependency in your pubspec.yaml file.
Import this dependency in file wherever you want to use and then you are good to go...
for picking single file use this code:
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
File file = File(result.files.single.path);
} else {
// User canceled the picker
}
files with extension filter:
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'pdf', 'doc'],
);
You can find detailed usage Here
you can find the documentation Here

How to handle file upload in WKWebview?

I am displaying a html page using WKWebview in Swift 5. I have an option to upload image using input file tag. When I run the app and click on upload, it prompts to select Photo library or Camera. If I select camera, app crashes since the app doesn't have permission.
How to remove camera option or properly request the permission when the user select camera?
I am not sure but you can just set key Privacy - Camera Usage Description in info.plist file with description. Web view will manage for permission and it will work. Please check and let me know if work for you.

How can I check whether the photo library is empty?

I am creating a button to let the user choose an image from their photo library, and I would like to hide this button if there are no images in the user’s photo library.
BOOL stillImagesAvailable = [[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary] containsObject:(NSString *)kUTTypeImage];
if (!stillImagesAvailable) {
// Hide button
return;
}
stillImagesAvailable = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary];
if (!stillImagesAvailable) {
// Hide button
return;
}
// Show button
+[UIImagePickerController isSourceTypeAvailable:] is documented to return NO if there are no photos in the library, but I'm seeing it return YES in this case on iOS 11 running on the simulator. Am I using this method wrong, or is the documentation incorrect, or am I running into a bug?
Is there another good way to detect whether there are any images in the user’s photo library?
UIImagePickerController doesn't expose this information. That class generally doesn't provide information about the user's photo library, merely some user-selected contents thereof. (The documentation you cite appears to be incorrect — I'd recommend filing a bug against the documentation for them to change it.)
Aside: The "user-selected" part is important in iOS 11 and later: the image picker runs in a separate process, meaning your app gets access only to the picked assets, meaning you don't have to ask the user for blanket read/write access to the Photos library through privacy settings.) Keep that privacy stuff in mind for further down in this answer, though...
If you need to learn about the contents of the user's Photos library, use the Photos framework. If specifically you want to know whether the library is "empty", you'll need to define what "empty" means for your app. No assets saved in the local library through iOS? No assets synced onto the device through iTunes? What if I have no assets, but I do have some empty albums?
Assuming one possible answer to those questions (no local or synced assets, don't care about albums), here's some (untested) code that should get your answer:
- (BOOL)isPhotoLibraryEmpty {
PHFetchOptions *options = [PHFetchOptions new];
options.includeAssetSourceTypes = PHAssetSourceTypeUserLibrary | PHAssetSourceTypeiTunesSynced;
PHFetchResult *results = [PHAsset fetchAssetsWithOptions:options];
return results.count == 0;
}
However, if this would be your app's only use of the Photos framework, it might be wiser to think about whether it's worthwhile to preemptively check for an empty library. If you use the Photos framework at all, your app needs blanket read/write access to the Photos library through the iOS privacy settings (that is, you provide a NSPhotoLibraryUsageDescription in your info.plist, and iOS prompts the user for permission the first time you call any Photos API).
For example, if all you're using the Photos framework for is to check for an empty library so you know whether to disable a "pick a photo" button in your UI... getting that deep into the privacy/permissions system probably isn't worth it. (Now you're actively interrupting them with a privacy prompt instead of passively disabling a button.) It's probably better to just let the user do whatever your UI does for invoking the image picker, and let UIImagePickerController show an appropriate screen if the library is empty (which it does).

How to display photo library permissions dialog in Cordova?

Hi we are developing an IBM MobileFirst Platform-based Hybrid Application. In our application we are accessing user gallery (to upload photos). for this in iPhone we need to ask the user permission explicitly, to ask user permission in iPhone we need to display dialog box. Here my question is the dialog box which we are going to show to the user is custom dialog box or is there any native feature built-in in MobileFirst, or with the help of any cordova plugin?
You can use requestCameraRollAuthorization() in cordova-diagnostic-plugin to request native iOS permission to access the user photos:
cordova.plugins.diagnostic.requestCameraRollAuthorization(function(granted){
console.log("Authorization request for camera roll was " + (granted ? "granted" : "denied"));
}, function(error){
console.error(error);
});
MobileFirst does not handle any permissions for you - it is not that kind of a framework. This really relates to the Cordova layer in your app, which access the photo library.
You need to display a dialog box asking the user whether or not does s/he allow for the access to access the photo library. You can use WL.SimpleDialog for this purpose, for example.
Read more here:
http://docs.phonegap.com/en/3.3.0/guide_appdev_privacy_index.md.html#Privacy%20Guide
Cordova Camera Plugin in IOS 9
perhaps to check if there is access given, create also a Cordova plug-in that will check for it using native code: Determine if the access to photo library is set or not - PHPhotoLibrary (iOS 8)

Checking permission before using UIImagePickerController

One of my earlier version of iOS app uses UIImagePickerController. During that development period there's no permissions involved to access the photos/videos from album. But in latest version, it asks for permission of user to access album.
How can I check if the user has granted permission for accessing the photo album on the device with the help of UIImagePickerController (not using ALAssetLibrary)?
Update:
Since the PhotoKit framework was introduced in iOS 8 the best way to determine status is on PHPhotoLibrary.
Objective-C:
[PHPhotoLibrary authorizationStatus];
Swift:
PHPhotoLibrary.authorizationStatus()
There isn't anything in the public interface for UIImagePickerController that could be used to determine photo data authorization status. Alas, it seems the only option for determining authorization status is +[ALAssetsLibrary authorizationStatus].

Resources