RNPermissions.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. @interface RNPermissions : NSObject <RCTBridgeModule>
  70. + (bool)isFlaggedAsRequested:(NSString * _Nonnull)handlerId;
  71. + (void)flagAsRequested:(NSString * _Nonnull)handlerId;
  72. + (bool)isBackgroundModeEnabled:(NSString * _Nonnull)mode;
  73. @end