#Camera with inertia react

1 messages · Page 1 of 1 (latest)

empty path
#

does anybody have idea how to use nativephp camera with inertia react ?

wanton forge
#

Are you targeting ios or android?

empty path
wanton forge
#

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

tall zodiac
#

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?

uneven skiff
tall zodiac
#

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! 😎

uneven skiff
#

What do you need to see?

errant yew
#

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?

tall zodiac
#

Im in the same scenary, actually idk what is wrong 🙁

uneven skiff
#

2 things to try

  1. chrome://inspect
  2. Native\\Mobile\\Events\\Gallery\\MediaSelected double \\