Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

ImagePicker.IsSourceTypeAvailable

Check for source availability.

Component Version macOS Windows Linux Server iOS SDK
ImagePicker 7.3 ❌ No ❌ No ❌ No ❌ No ✅ Yes
MBS( "ImagePicker.IsSourceTypeAvailable"; sourceType )   More

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 " & $sourceType & " 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

Example Databases

Blog Entries

This function is free to use.

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


ImagePicker.IsPresented - ImagePicker.MediaCropRect