Created
March 5, 2019 18:29
-
-
Save exclusiveTanim/e3b3d09764ceadb93ca6d16ebdfcc6cb to your computer and use it in GitHub Desktop.
iPhone X camera issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*- Yes this only happens on iPhone X series (seems like the extra space created by the notch at the top might be the cause?) | |
- Another factor might be that they're not using the native controls of the camera, but instead they have an OVERLAY view with a custom button for actions.*/ | |
function showCamera(){ | |
// This is a custom view that has a button for start / stop the record | |
const overlay = Alloy.createController('overlay', { | |
fnStartRecording: index => { | |
question = index; | |
Ti.Media.startVideoCapture(); | |
}, | |
fnStopRecording: () => { | |
Ti.Media.stopVideoCapture(); | |
} | |
}).getView(); | |
Ti.Media.showCamera({ | |
success: e => { | |
// Other thread | |
}, | |
cancel: e => { | |
Ti.Media.hideCamera(); | |
}, | |
error: e => { | |
// TODO: manejo de errores | |
Ti.Media.hideCamera(); | |
}, | |
animated: false, | |
overlay, | |
autohide: false, | |
showControls: false, | |
saveToPhotoGallery: false, // save our media to the gallery | |
mediaTypes: [Ti.Media.MEDIA_TYPE_VIDEO], | |
whichCamera: 1 // Seems like this only works with Android | |
}); | |
// Show the front camera | |
if (Ti.Media.camera == 0) { // back camera | |
Ti.Media.switchCamera(1); // front camera | |
} | |
} | |
if (!Ti.Media.hasCameraPermissions()) { | |
$.pages.scrollToView($.page3); <- This is not necesary for you, is our custom page to request permissions | |
// request permissions to capture media | |
Ti.Media.requestCameraPermissions(e => { | |
// success! we can capture media! | |
if (e.success) { | |
openCamera() | |
} else { | |
$.pages.scrollToView($.page4); <- This is a custom page to show that you denied permissions for the camera | |
} | |
}); | |
} else { | |
// yay! we already have permissions! | |
require('navigation').goTo('interview', { animated: true, interview, onOpen: () => { } }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment