52
Views
5
Comments
How can I use navigator.share API?

Hello guys!

I'm new here and I'm not a good programmer, but I'm trying to create an app with outSystems which is a fantastic tool. Forgive me if you find any silly mistakes.

I'm trying to implement a function to share an image.
Here are some screenshots about the problem:

I implemented it like this

When I open it in the browser, it works.

 But when I try to run in the app installed on the android phone, it doesn't work 


This is part of a larger solution, but create a specific file (Share.oap) to attach here to share what I'm trying.

I tried to use some modules available in Forge, but I couldn't put it to work either.

But I think it will be much simpler if it works in javascript.

Can someone help me?

Share.oap
UserImage.jpg
Mauro Lucio da Silva Junior

Hey guys!

Can someone help me?

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

Which browser are you using. The share method is only available over https:// and only supported by a limited set of browsers, see 

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share

Regards,

Daniel

UserImage.jpg
Mauro Lucio da Silva Junior

Thanks for the guidance Daniel.

I checked it out.

When I run the code in the same browser outside the APP it works. The same code in the APP does not work.

2024-06-13 07-53-34
Paulo Moreira
 
MVP

Hi Mauro,

The query selector you're using on your javascript code is incorrect. In Outsystems, widgets have a runtime Id that is not exactly what you define as its name on Service Studio.

In your case, you should pass the btnShare icon runtime id as an input parameter to your javascript code, and change that code as follows:

Hope this helps.

Best regards,

Paulo Moreira

UserImage.jpg
Mauro Lucio da Silva Junior

Thank you for your contribution Paulo.

The Button was working normally. The function was called but does not recognize the navigator.share call

However, I implemented your suggestion and the error remains.


Best regards,

Mauro Jr.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.