mercredi 22 juin 2016

Camera permissions on iOS9 seems to be iPhone 6 specific

I'm have issues with the test-flight version of our app when attempting to take a photo. On most devices everything works fine, but something seems to be going wrong, specifically on iPhone 6. Because we don't have an iPhone 6 it's very hard to find out what the issue is without console output.

Our camera calling code looks like this (note some of this is specific to the Moai platform):

int MOAIAppIOS::_takeCamera( lua_State* L ) {

int x, y, width, height = 0;
NSUInteger sourceType;

MOAILuaState state ( L );
if ( state.IsType ( 1, LUA_TFUNCTION )) {
    MOAIAppIOS::Get ().mOnTakeCameraCallback.SetRef ( state, 1 );
}

sourceType = state.GetValue < NSUInteger >( 2, 0 );
x = state.GetValue < int >( 3, 0 );
y = state.GetValue < int >( 4, 0 );
width = state.GetValue < int >( 5, 0 );
height = state.GetValue < int >( 6, 0 );

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
 {
     if (granted == true)
     {
         UIImagePickerNoRotate *ipc = [[UIImagePickerNoRotate alloc]
                                       init];
         UIWindow* window = [[ UIApplication sharedApplication ] keyWindow ];
         UIViewController* rootVC = [ window rootViewController ];

         ipc.delegate = MOAIAppIOS::Get ().mTakeCameraListener;
         ipc.sourceType = sourceType;
         [rootVC presentViewController:ipc animated:YES completion:nil];

     }
     else
     {
         NSLog(@"denied");
     }

 }];



return 0;
}
void MOAIAppIOS::callTakeCameraLuaCallback (NSString *imagePath) {
    MOAILuaRef& callback = MOAIAppIOS::Get ().mOnTakeCameraCallback;
    MOAIScopedLuaState state = callback.GetSelf ();
    state.Push ([imagePath UTF8String]);
    state.DebugCall ( 1, 0 );
    NSLog(@"callback sent");
}

I also added the following to the pList:

<key>NSCameraUsageDescription</key>
<string>Camera is used to add custom items to the game</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone is used to record custom items for the game</string>

These seemed like a very similar issues:
iOS Camera permissions doesn't appear under settings in some devices

Permission to take photo OR get image from library not shown in iOS9 (Xcode 7beta, Swift2)

But I have tried all the fixes there to no avail.

Aucun commentaire:

Enregistrer un commentaire