Photos & files
Count and clear the photos and videos in the library, save images or videos into it, and download files into the app. The first call asks for photo library access.
نظرة عامة
- ·Saving and deleting return true / false only after the system has finished
- ·Deleting taps through the system confirmation for you
getPicCount#
The number of images in the photo library (videos excluded).
getPicCount(): number;القيمة المُعادة
| النوع | الوصف |
|---|---|
number | The image count, or 0 without photo access (a log line says so). |
مثال
logi('photos: ' + getPicCount());انظر أيضًا getVideoCount
getVideoCount#
The number of videos in the photo library.
getVideoCount(): number;القيمة المُعادة
| النوع | الوصف |
|---|---|
number | The video count, or 0 without photo access. |
مثال
logi('videos: ' + getVideoCount());انظر أيضًا getPicCount
deleteAllPic#
Delete every image in the photo library.
deleteAllPic(): boolean;القيمة المُعادة
| النوع | الوصف |
|---|---|
boolean | Returns once deletion has finished: true on success (or when there was nothing to delete), false on failure (no photo access, the prompt was declined, …) with the reason in the error log. |
الاستثناءات
| الاستثناء | متى يحدث |
|---|---|
WDAErrorFEATURE_UNAVAILABLE | The app on the device is too old to have this feature; update the app. |
ملاحظات
- iOS always asks for confirmation before deleting from the photo library; the script taps Delete for you, switching to the Photos app and back in the process.
- Deleted items go to Recently Deleted first and can be recovered for 30 days; iOS offers no public way to empty Recently Deleted.
مثال
if (!deleteAllPic()) {
return false;
}انظر أيضًا deleteAllVideo、deleteAllPicAndVideo
deleteAllVideo#
Delete every video in the photo library. Works like deleteAllPic.
deleteAllVideo(): boolean;القيمة المُعادة
| النوع | الوصف |
|---|---|
boolean | Returns once deletion has finished: true on success (or when there was nothing to delete), false on failure (no photo access, the prompt was declined, …) with the reason in the error log. |
الاستثناءات
| الاستثناء | متى يحدث |
|---|---|
WDAErrorFEATURE_UNAVAILABLE | The app on the device is too old to have this feature; update the app. |
ملاحظات
- iOS always asks for confirmation before deleting from the photo library; the script taps Delete for you, switching to the Photos app and back in the process.
- Deleted items go to Recently Deleted first and can be recovered for 30 days; iOS offers no public way to empty Recently Deleted.
مثال
deleteAllVideo();انظر أيضًا deleteAllPic
deleteAllPicAndVideo#
Delete every image and video in the photo library. Works like deleteAllPic.
deleteAllPicAndVideo(): boolean;القيمة المُعادة
| النوع | الوصف |
|---|---|
boolean | Returns once deletion has finished: true on success (or when there was nothing to delete), false on failure (no photo access, the prompt was declined, …) with the reason in the error log. |
الاستثناءات
| الاستثناء | متى يحدث |
|---|---|
WDAErrorFEATURE_UNAVAILABLE | The app on the device is too old to have this feature; update the app. |
ملاحظات
- iOS always asks for confirmation before deleting from the photo library; the script taps Delete for you, switching to the Photos app and back in the process.
- Deleted items go to Recently Deleted first and can be recovered for 30 days; iOS offers no public way to empty Recently Deleted.
مثال
deleteAllPicAndVideo();انظر أيضًا deleteAllPic
savePicVideo#
Save an image or a video into the photo library; the file extension decides which.
savePicVideo(pathOrBase64: string, filename?: string): boolean;المعاملات
| الاسم | النوع | مطلوب | القيمة الافتراضية | الوصف |
|---|---|---|---|---|
pathOrBase64 | string | نعم | — | A file path inside the app (relative to its Documents folder; files from downloadAndSaveFile live under sync/), or base64 data (a data: prefix is accepted). |
filename | string | لا | — | With base64 data, its extension decides image or video — for example cover.jpg or intro.mp4. |
القيمة المُعادة
| النوع | الوصف |
|---|---|
boolean | Returns once the system has actually written the item: true on success, false on failure with the reason in the error log. |
الاستثناءات
| الاستثناء | متى يحدث |
|---|---|
WDAErrorFEATURE_UNAVAILABLE | The app on the device is too old to have this feature; update the app. |
مثال
savePicVideo('sync/intro.mp4');
savePicVideo(client.screenshot(), 'screen.png');انظر أيضًا downloadAndSaveFile、downloadAndSavePicVideo
downloadAndSavePicVideo#
Download an image or a video and save it into the photo library; the downloaded content decides which.
downloadAndSavePicVideo(url: string): boolean;المعاملات
| الاسم | النوع | مطلوب | القيمة الافتراضية | الوصف |
|---|---|---|---|---|
url | string | نعم | — | The download address. An address starting with / is resolved against the server (for example a File Sync file). |
القيمة المُعادة
| النوع | الوصف |
|---|---|
boolean | Returns once the system has actually written the item: true on success, false on failure with the reason in the error log. |
الاستثناءات
| الاستثناء | متى يحدث |
|---|---|
WDAErrorFEATURE_UNAVAILABLE | The app on the device is too old to have this feature; update the app. |
مثال
downloadAndSavePicVideo('https://example.com/a.mp4');انظر أيضًا savePicVideo
downloadAndSaveFile#
Download any file into the app's sync/ folder (visible in the Files app under On My iPhone → WTScript → sync), named after the last segment of the address.
downloadAndSaveFile(url: string): boolean;المعاملات
| الاسم | النوع | مطلوب | القيمة الافتراضية | الوصف |
|---|---|---|---|---|
url | string | نعم | — | The full download address (starting with http:// or https://). |
القيمة المُعادة
| النوع | الوصف |
|---|---|
boolean | True when the file was downloaded and saved. Waits 120 seconds at most. |
مثال
if (downloadAndSaveFile('https://example.com/intro.mp4')) {
savePicVideo('sync/intro.mp4');
}انظر أيضًا savePicVideo