ImagePicker.IsSourceTypeAvailable
---------------------------------

Check for source availability.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [ImagePicker](component_ImagePicker.md) | [7.3](newinversion73.md) | ❌ No | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "ImagePicker.IsSourceTypeAvailable"; sourceType ) 

**MBS**( **"ImagePicker.IsSourceTypeAvailable"** /\* Check for source availability. \*/  
**$sourceType**) /\* The source to use to pick an image.  
Can be PhotoLibrary, Camera or SavedPhotosAlbum. e.g. "Camera" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| sourceType | The source to use to pick an image.   Can be PhotoLibrary, Camera or SavedPhotosAlbum. | "Camera" |

### Result

Returns OK or error.

### Description

Check for source availability.  
Returns a Boolean value indicating whether the device supports picking media using the specified source type.  
1 if the device supports the specified source type; 0 if the specified source type is not available.  
Because a media source may not be present or may be unavailable, devices may not always support all source types. For example, if you attempt to pick an image from the user’s library and the library is empty, this method returns 0. Similarly, if the camera is already in use, this method returns 0.  
Before attempting to use an ImagePickerController object to pick an image, you must call this method to ensure that the desired source type is available.  
### Examples

Check for source type being available:

 Set Variable \[ $SourceType ; Value: Get(ScriptParameter) \]   
Set Variable \[ $r ; Value: MBS ( "ImagePicker.IsSourceTypeAvailable"; $sourceType ) \]   
If \[ $r ≠ 1 \]   
 Show Custom Dialog \[ "Can't pick picture." ; "The source " &amp; $sourceType &amp; " is not available." \]   
 Exit Script \[ Text Result: "failed" \]   
End If  
Check availability:

 Set Variable \[ $CameraAvailable ; Value: MBS ("ImagePicker.IsSourceTypeAvailable"; "Camera") \]   
Set Variable \[ $PhotoLibraryAvailable ; Value: MBS ("ImagePicker.IsSourceTypeAvailable"; "PhotoLibrary") \]   
Set Variable \[ $SavedPhotosAlbumAvailable ; Value: MBS ("ImagePicker.IsSourceTypeAvailable"; "SavedPhotosAlbum") \]  
### See also

- [ImagePicker.AvailableMediaTypesForSourceType](ImagePickerAvailableMediaTypesForSourceType.md)
- [ImagePicker.IsCameraDeviceAvailable](ImagePickerIsCameraDeviceAvailable.md)

### Example Databases

- [iOS/Examples/iOS ImagePicker](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/iOS/Examples/iOS%20ImagePicker.shtml#4ScriptAnchor_)

### Blog Entries

- [Image Picker for FileMaker iOS SDK apps with MBS Plugin](https://www.mbsplugins.de/archive/2017-06-20/Image_Picker_for_FileMaker_iOS/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 17th June 2017 , last changed 2nd May 2023

  
[ImagePicker.IsPresented](ImagePickerIsPresented.md) - [ImagePicker.MediaCropRect](ImagePickerMediaCropRect.md)

[HTML Version](ImagePickerIsSourceTypeAvailable.shtml)