#Camera with inertia react
1 messages · Page 1 of 1 (latest)
Are you targeting ios or android?
Android sir
To open the camera you just need to use the System::camera() method of the Native\Mobile\Facades\System facade on the PHP side in response to some action - this will open the camera
Then in javascript you'd listen for the Native::on('Native\\Mobile\\Events\\Camera\\PhotoTaken', ($path) => {}) event.
Your JS callback will need to pass this path back to a PHP action, that can then do whatever you need to do with the file
docs will be improved around this very soon
Hi @wanton forge, I actually do this with Inertia + vue, I think is same base, that you suggest is make an action to call the System::camera(), maybe a route to open and then with the listener in front get the file and after send this file to my api for example?
System::camera() was deprecated, use the Camera facade: https://nativephp.com/docs/mobile/1/apis/camera
Nice! I just saw your announcement about toasts and tokens for push notifications with Inertia — can’t wait to see something similar coming for the camera soon! 😎
What do you need to see?
Hi @uneven skiff @wanton forge
I'm using laravel inertia vue.
Opening the gallery works fine with this code:
public function gallery(string $media_type = 'all', bool $multiple = false, int $max_items = 5)
{
Camera::pickImages($media_type, $multiple, $max_items);
}
const gallery = (media_type: any) => {
console.log('GALLERY');
router.get(
route('tasks.gallery'),
{
media_type: media_type,
},
{
preserveScroll: true,
preserveState: true,
onSuccess: function (result) {
console.log('GALLERY', result);
},
},
);
};
But when the media is selected, it doesn’t work.
Here’s the listener:
onMounted(() => {
Native::on('Native\Mobile\Events\Gallery\MediaSelected', (payload) => {
console.log('received via window.Native.on', payload);
alert('received via window.Native.on: ' + JSON.stringify(payload));
}) ;
(window as any).Native?.on('Native\\Mobile\\Events\\Gallery\\MediaSelected', (payload: any) => {
console.log('received via window.Native.on', payload);
alert('received via window.Native.on: ' + JSON.stringify(payload));
});
});
Am I missing something?
Im in the same scenary, actually idk what is wrong 🙁
2 things to try
- chrome://inspect
- Native\\Mobile\\Events\\Gallery\\MediaSelected double \\