Skip to content

Commit cd81cfa

Browse files
authored
feat(diagnostic): addisCameraRollAuthorized and getCameraRollAuthorizationStatus functions (WIP) (#4362)
1 parent 81a8b42 commit cd81cfa

File tree

1 file changed

+41
-8
lines changed
  • src/@awesome-cordova-plugins/plugins/diagnostic

1 file changed

+41
-8
lines changed

src/@awesome-cordova-plugins/plugins/diagnostic/index.ts

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ export class Diagnostic extends AwesomeCordovaNativePlugin {
153153
UNKNOWN: string;
154154
};
155155

156+
/**
157+
* Access to the photo library (iOS 14+)
158+
*
159+
* ADD_ONLY - can add to but not read from Photo Library
160+
* READ_WRITE - can both add to and read from Photo Library
161+
*
162+
*/
163+
photoLibraryAccessLevel = {
164+
ADD_ONLY: 'add_only',
165+
READ_WRITE: 'read_write',
166+
};
167+
156168
/**
157169
* Checks if app is able to access device location.
158170
*
@@ -814,20 +826,34 @@ export class Diagnostic extends AwesomeCordovaNativePlugin {
814826
/**
815827
* Checks if the application is authorized to use the Camera Roll in Photos app.
816828
*
829+
* @param accessLevel - (optional) On iOS 14+, specifies the level of access to the photo library to query as a constant in cordova.plugins.diagnostic.photoLibraryAccessLevel`
830+
* Possible values are:
831+
* ADD_ONLY - can add to but not read from Photo Library
832+
* READ_WRITE - can both add to and read from Photo Library
833+
* Defaults to ADD_ONLY if not specified
834+
* Has no effect on iOS 13 or below
835+
*
817836
* @returns {Promise<boolean>}
818837
*/
819-
@Cordova({ platforms: ['iOS'] })
820-
isCameraRollAuthorized(): Promise<boolean> {
838+
@Cordova({ platforms: ['iOS'], callbackOrder: 'reverse' })
839+
isCameraRollAuthorized(accessLevel?: string): Promise<boolean> {
821840
return;
822841
}
823842

824843
/**
825844
* Returns the authorization status for the application to use the Camera Roll in Photos app.
826845
*
846+
* @param accessLevel - (optional) On iOS 14+, specifies the level of access to the photo library to query as a constant in cordova.plugins.diagnostic.photoLibraryAccessLevel`
847+
* Possible values are:
848+
* ADD_ONLY - can add to but not read from Photo Library
849+
* READ_WRITE - can both add to and read from Photo Library
850+
* Defaults to ADD_ONLY if not specified
851+
* Has no effect on iOS 13 or below
852+
*
827853
* @returns {Promise<string>}
828854
*/
829-
@Cordova({ platforms: ['iOS'] })
830-
getCameraRollAuthorizationStatus(): Promise<string> {
855+
@Cordova({ platforms: ['iOS'], callbackOrder: 'reverse' })
856+
getCameraRollAuthorizationStatus(accessLevel?: string): Promise<string> {
831857
return;
832858
}
833859

@@ -836,10 +862,17 @@ export class Diagnostic extends AwesomeCordovaNativePlugin {
836862
* Should only be called if authorization status is NOT_REQUESTED.
837863
* Calling it when in any other state will have no effect.
838864
*
865+
* @param accessLevel - (optional) On iOS 14+, specifies the level of access to the photo library to query as a constant in cordova.plugins.diagnostic.photoLibraryAccessLevel`
866+
* Possible values are:
867+
* ADD_ONLY - can add to but not read from Photo Library
868+
* READ_WRITE - can both add to and read from Photo Library
869+
* Defaults to ADD_ONLY if not specified
870+
* Has no effect on iOS 13 or below
871+
*
839872
* @returns {Promise<any>}
840873
*/
841-
@Cordova({ platforms: ['iOS'] })
842-
requestCameraRollAuthorization(): Promise<any> {
874+
@Cordova({ platforms: ['iOS'], callbackOrder: 'reverse' })
875+
requestCameraRollAuthorization(accessLevel?: string): Promise<any> {
843876
return;
844877
}
845878

@@ -1006,13 +1039,13 @@ export class Diagnostic extends AwesomeCordovaNativePlugin {
10061039
}
10071040

10081041
/**
1009-
* Returns the location accuracy authorization for the application on iOS 14+. Note: calling on iOS <14 will result in the Promise being rejected.
1042+
* Returns the location accuracy authorization for the application on iOS 14+ and Android 12+. Note: calling on iOS <14 or Android <12 will always return cordova.plugins.diagnostic.locationAccuracyAuthorization.FULL
10101043
*
10111044
* Learn more about this method [here](https://github.com/dpa99c/cordova-diagnostic-plugin#getlocationaccuracyauthorization)
10121045
*
10131046
* @returns {Promise<string>}
10141047
*/
1015-
@Cordova({ platform: ['iOS'] })
1048+
@Cordova({ platforms: ['iOS', 'Android'] })
10161049
getLocationAccuracyAuthorization(): Promise<string> {
10171050
return;
10181051
}

0 commit comments

Comments
 (0)