RNPermissions.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #import <React/RCTBridgeModule.h>
  2. #import <React/RCTConvert.h>
  3. typedef NS_ENUM(NSInteger, RNPermission) {
  4. RNPermissionUnknown = 0,
  5. #if __has_include("RNPermissionHandlerBluetoothPeripheral.h")
  6. RNPermissionBluetoothPeripheral = 1,
  7. #endif
  8. #if __has_include("RNPermissionHandlerCalendars.h")
  9. RNPermissionCalendars = 2,
  10. #endif
  11. #if __has_include("RNPermissionHandlerCamera.h")
  12. RNPermissionCamera = 3,
  13. #endif
  14. #if __has_include("RNPermissionHandlerContacts.h")
  15. RNPermissionContacts = 4,
  16. #endif
  17. #if __has_include("RNPermissionHandlerFaceID.h")
  18. RNPermissionFaceID = 5,
  19. #endif
  20. #if __has_include("RNPermissionHandlerLocationAlways.h")
  21. RNPermissionLocationAlways = 6,
  22. #endif
  23. #if __has_include("RNPermissionHandlerLocationWhenInUse.h")
  24. RNPermissionLocationWhenInUse = 7,
  25. #endif
  26. #if __has_include("RNPermissionHandlerMediaLibrary.h")
  27. RNPermissionMediaLibrary = 8,
  28. #endif
  29. #if __has_include("RNPermissionHandlerMicrophone.h")
  30. RNPermissionMicrophone = 9,
  31. #endif
  32. #if __has_include("RNPermissionHandlerMotion.h")
  33. RNPermissionMotion = 10,
  34. #endif
  35. #if __has_include("RNPermissionHandlerPhotoLibrary.h")
  36. RNPermissionPhotoLibrary = 11,
  37. #endif
  38. #if __has_include("RNPermissionHandlerReminders.h")
  39. RNPermissionReminders = 12,
  40. #endif
  41. #if __has_include("RNPermissionHandlerSiri.h")
  42. RNPermissionSiri = 13,
  43. #endif
  44. #if __has_include("RNPermissionHandlerSpeechRecognition.h")
  45. RNPermissionSpeechRecognition = 14,
  46. #endif
  47. #if __has_include("RNPermissionHandlerStoreKit.h")
  48. RNPermissionStoreKit = 15,
  49. #endif
  50. };
  51. @interface RCTConvert (RNPermission)
  52. @end
  53. typedef enum {
  54. RNPermissionStatusNotAvailable = 0,
  55. RNPermissionStatusNotDetermined = 1,
  56. RNPermissionStatusRestricted = 2,
  57. RNPermissionStatusDenied = 3,
  58. RNPermissionStatusAuthorized = 4,
  59. } RNPermissionStatus;
  60. @protocol RNPermissionHandler <NSObject>
  61. @required
  62. + (NSArray<NSString *> * _Nonnull)usageDescriptionKeys;
  63. + (NSString * _Nonnull)handlerUniqueId;
  64. - (void)checkWithResolver:(void (^ _Nonnull)(RNPermissionStatus status))resolve
  65. rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject;
  66. - (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus status))resolve
  67. rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject;
  68. @end
  69. @interface RNPermissions : NSObject <RCTBridgeModule>
  70. + (bool)isFlaggedAsRequested:(NSString * _Nonnull)handlerId;
  71. + (void)flagAsRequested:(NSString * _Nonnull)handlerId;
  72. @end