12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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,
  7. #endif
  8. #if __has_include("RNPermissionHandlerCalendars.h")
  9. RNPermissionCalendars,
  10. #endif
  11. #if __has_include("RNPermissionHandlerCamera.h")
  12. RNPermissionCamera,
  13. #endif
  14. #if __has_include("RNPermissionHandlerContacts.h")
  15. RNPermissionContacts,
  16. #endif
  17. #if __has_include("RNPermissionHandlerFaceID.h")
  18. RNPermissionFaceID,
  19. #endif
  20. #if __has_include("RNPermissionHandlerLocationAlways.h")
  21. RNPermissionLocationAlways,
  22. #endif
  23. #if __has_include("RNPermissionHandlerLocationWhenInUse.h")
  24. RNPermissionLocationWhenInUse,
  25. #endif
  26. #if __has_include("RNPermissionHandlerMediaLibrary.h")
  27. RNPermissionMediaLibrary,
  28. #endif
  29. #if __has_include("RNPermissionHandlerMicrophone.h")
  30. RNPermissionMicrophone,
  31. #endif
  32. #if __has_include("RNPermissionHandlerMotion.h")
  33. RNPermissionMotion,
  34. #endif
  35. #if __has_include("RNPermissionHandlerPhotoLibrary.h")
  36. RNPermissionPhotoLibrary,
  37. #endif
  38. #if __has_include("RNPermissionHandlerReminders.h")
  39. RNPermissionReminders,
  40. #endif
  41. #if __has_include("RNPermissionHandlerSiri.h")
  42. RNPermissionSiri,
  43. #endif
  44. #if __has_include("RNPermissionHandlerSpeechRecognition.h")
  45. RNPermissionSpeechRecognition,
  46. #endif
  47. #if __has_include("RNPermissionHandlerStoreKit.h")
  48. RNPermissionStoreKit,
  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. @protocol RNPermissionWithRequestOptions <NSObject>
  70. @required
  71. - (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus status))resolve
  72. rejecter:(void (^ _Nonnull)(NSError * _Nonnull error))reject
  73. options:(NSArray<NSString *> * _Nonnull)options;
  74. @end
  75. @interface RNPermissions : NSObject <RCTBridgeModule>
  76. + (bool)hasAlreadyBeenRequested:(id<RNPermissionHandler> _Nonnull)handler;
  77. + (bool)isBackgroundModeEnabled:(NSString * _Nonnull)mode;
  78. @end