Skip to content

Commit ee49dd7

Browse files
majakFacebook Github Bot 5
authored andcommitted
check for NSPhotoLibraryUsageDescription in plist
Reviewed By: javache Differential Revision: D3723122 fbshipit-source-id: a5393c7dd3c36a15bec3f2e79859920419cc6726
1 parent 26e8ae7 commit ee49dd7

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Examples/UIExplorer/UIExplorer/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,7 @@
5656
</array>
5757
<key>UIViewControllerBasedStatusBarAppearance</key>
5858
<false/>
59+
<key>NSPhotoLibraryUsageDescription</key>
60+
<string>You need to add NSPhotoLibraryUsageDescription key in Info.plist to enable photo library usage, otherwise it is going to *fail silently*!</string>
5961
</dict>
6062
</plist>

Libraries/CameraRoll/RCTCameraRollManager.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
147147
resolve:(RCTPromiseResolveBlock)resolve
148148
reject:(RCTPromiseRejectBlock)reject)
149149
{
150+
checkPhotoLibraryConfig();
151+
150152
NSUInteger first = [RCTConvert NSInteger:params[@"first"]];
151153
NSString *afterCursor = [RCTConvert NSString:params[@"after"]];
152154
NSString *groupName = [RCTConvert NSString:params[@"groupName"]];
@@ -221,4 +223,13 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
221223
}];
222224
}
223225

226+
static void checkPhotoLibraryConfig()
227+
{
228+
#if RCT_DEV
229+
if (![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSPhotoLibraryUsageDescription"]) {
230+
RCTLogError(@"NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll.");
231+
}
232+
#endif
233+
}
234+
224235
@end

Libraries/Geolocation/RCTLocationObserver.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ - (void)timeout:(NSTimer *)timer
174174

175175
RCT_EXPORT_METHOD(startObserving:(RCTLocationOptions)options)
176176
{
177-
[self checkLocationConfig];
177+
checkLocationConfig();
178178

179179
// Select best options
180180
_observerOptions = options;
@@ -201,7 +201,7 @@ - (void)timeout:(NSTimer *)timer
201201
withSuccessCallback:(RCTResponseSenderBlock)successBlock
202202
errorCallback:(RCTResponseSenderBlock)errorBlock)
203203
{
204-
[self checkLocationConfig];
204+
checkLocationConfig();
205205

206206
if (!successBlock) {
207207
RCTLogError(@"%@.getCurrentPosition called with nil success parameter.", [self class]);
@@ -339,12 +339,14 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
339339
}
340340
}
341341

342-
- (void)checkLocationConfig
342+
static void checkLocationConfig()
343343
{
344+
#if RCT_DEV
344345
if (!([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] ||
345346
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"])) {
346347
RCTLogError(@"Either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription key must be present in Info.plist to use geolocation.");
347348
}
349+
#endif
348350
}
349351

350352
@end

0 commit comments

Comments
 (0)