mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 02:04:55 +00:00
check for NSPhotoLibraryUsageDescription in plist
Reviewed By: javache Differential Revision: D3723122 fbshipit-source-id: a5393c7dd3c36a15bec3f2e79859920419cc6726
This commit is contained in:
parent
26e8ae74b6
commit
ee49dd756d
@ -56,5 +56,7 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
|
<string>You need to add NSPhotoLibraryUsageDescription key in Info.plist to enable photo library usage, otherwise it is going to *fail silently*!</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -147,6 +147,8 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
|||||||
resolve:(RCTPromiseResolveBlock)resolve
|
resolve:(RCTPromiseResolveBlock)resolve
|
||||||
reject:(RCTPromiseRejectBlock)reject)
|
reject:(RCTPromiseRejectBlock)reject)
|
||||||
{
|
{
|
||||||
|
checkPhotoLibraryConfig();
|
||||||
|
|
||||||
NSUInteger first = [RCTConvert NSInteger:params[@"first"]];
|
NSUInteger first = [RCTConvert NSInteger:params[@"first"]];
|
||||||
NSString *afterCursor = [RCTConvert NSString:params[@"after"]];
|
NSString *afterCursor = [RCTConvert NSString:params[@"after"]];
|
||||||
NSString *groupName = [RCTConvert NSString:params[@"groupName"]];
|
NSString *groupName = [RCTConvert NSString:params[@"groupName"]];
|
||||||
@ -221,4 +223,13 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void checkPhotoLibraryConfig()
|
||||||
|
{
|
||||||
|
#if RCT_DEV
|
||||||
|
if (![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSPhotoLibraryUsageDescription"]) {
|
||||||
|
RCTLogError(@"NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -174,7 +174,7 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
RCT_EXPORT_METHOD(startObserving:(RCTLocationOptions)options)
|
RCT_EXPORT_METHOD(startObserving:(RCTLocationOptions)options)
|
||||||
{
|
{
|
||||||
[self checkLocationConfig];
|
checkLocationConfig();
|
||||||
|
|
||||||
// Select best options
|
// Select best options
|
||||||
_observerOptions = options;
|
_observerOptions = options;
|
||||||
@ -201,7 +201,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
|
|||||||
withSuccessCallback:(RCTResponseSenderBlock)successBlock
|
withSuccessCallback:(RCTResponseSenderBlock)successBlock
|
||||||
errorCallback:(RCTResponseSenderBlock)errorBlock)
|
errorCallback:(RCTResponseSenderBlock)errorBlock)
|
||||||
{
|
{
|
||||||
[self checkLocationConfig];
|
checkLocationConfig();
|
||||||
|
|
||||||
if (!successBlock) {
|
if (!successBlock) {
|
||||||
RCTLogError(@"%@.getCurrentPosition called with nil success parameter.", [self class]);
|
RCTLogError(@"%@.getCurrentPosition called with nil success parameter.", [self class]);
|
||||||
@ -339,12 +339,14 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)checkLocationConfig
|
static void checkLocationConfig()
|
||||||
{
|
{
|
||||||
|
#if RCT_DEV
|
||||||
if (!([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] ||
|
if (!([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] ||
|
||||||
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"])) {
|
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"])) {
|
||||||
RCTLogError(@"Either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription key must be present in Info.plist to use geolocation.");
|
RCTLogError(@"Either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription key must be present in Info.plist to use geolocation.");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user