Mobile Sharing an Image via Whatsapp

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Tue Dec 18, 2018 1:53 am

Regarding
Just out of curiosity, what happens when you enter the whatsapp address into the address bar of the web browser on the device?
I had that curiosity as well and tried it at the very beginning
If I insert the same URL on my WebBrowser (both iPhone and desktop) the WhatsApp picking contact window opens as expected.
I "guess" I might have a clue, looking at the Launch URL documentation I see that it supports only 3 types of URL
urltipes.jpg
which of course would leave whatsapp: out of the equation resulting on an error (which shouldn't be the one I'm getting but that's another story).

But why does it work then on the desktop? I'm going to ask this on the Quality board...
Simon
________________________________________
To ";" or not to ";" that is the question

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Mobile Sharing an Image via Whatsapp

Post by SparkOut » Tue Dec 18, 2018 3:44 am

I have no real clue, and not an Apple user but I imagine you would need to edit the plist to create the custom url association.
The faq link already quoted does say "Be sure to include WhatsApp URL scheme in your application's Info.plist under LSApplicationQueriesSchemes key if you want to query presence of WhatsApp on user's iPhone using -[UIApplication canOpenURL:]."
Quite what you need to do to edit the plist, I am not sure, but I suspect that you are mostly there, if you get that edit done correctly.

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Tue Dec 18, 2018 10:40 am

@SparkOut I guess you are right. I will explore editing the plist (sounds like rock science to me but I will give a try) as outlined on this lesson
Will report the result here.

p.s. the funny thing is that I choose LC because it was "high level" with no need to go too deep into the details :D
Simon
________________________________________
To ";" or not to ";" that is the question

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Mobile Sharing an Image via Whatsapp

Post by bogs » Tue Dec 18, 2018 12:44 pm

simon.schvartzman wrote:
Tue Dec 18, 2018 1:53 am
I had that curiosity as well and tried it at the very beginning
Ah. I did re-scan the entire thread to see if you had already tried this, apparently my comprehension skills weren't up to the challenge. That is 2 :oops: in one thread for me :x <sigh>

It sounds (as you already said) like SparkOut has the answer, if program associations for iOs are configured through the plist, then that is the missing special ingredient. I'd never have guessed that one (but probably should have).

Lc itself is 'high level', the reason you chose it was valid. Associations, though, as I mentioned above, are set through the OS your running on, and the methods to set them up are not made by Lc. That would go for any OS you were programming for, in any language.

If you were writing a program for Windows for instance, and you needed (without user intervention) to have your program open when someone clicked on a certain type of file, you can see the steps are basically similar ~
http://www.owenpellegrin.com/blog/net/programmatically-creating-windows-file-associations/ wrote: In order to make it so that when you double-click a file your application opens you need three things:

Your application should support opening a file from the command-line in some way.
  • You need a registry key to associate a file type with the extension.
  • You need a registry key to associate a program with the file type.
Even if you were using VisualStudio, MSs own IDE, there isn't (or wasn't, last time I used it) any way to do this 'automatically' from inside a language.

It sounds like the pList is Apples version of the registry, all keys you need then have to be created by you.
Image

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Tue Dec 18, 2018 3:25 pm

Hi guys, good news. With the usual great support from Panos I ended up reading the Lesson Using custom URL schemes found here http://lessons.livecode.com/m/4069/l/58 ... rl-schemes
(why I didn't do it earlier! shame on me)

Adding "whatsapp" on "Custom URL Scheme" field of the Basic iOS standalone setting did the trick! It was muuuuch easier than I thought.
scre.jpg
Edited: the bad news is that this method doesn't allow to share pictures (which is my goal) just text...

Anyway many thanks to all that answered and hope it helps somebody in the future
Simon
________________________________________
To ";" or not to ";" that is the question

bwmilby
Posts: 439
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Mobile Sharing an Image via Whatsapp

Post by bwmilby » Tue Dec 18, 2018 10:56 pm

Did you look at mergPopActivity as a possible solution?
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Wed Dec 19, 2018 12:42 am

@bwmilby, I did not consider mergPopActivity before and after learning about it, is clear that it delivers exactly what I need. Many thanks for pointing me to it.

I guess I should have spent more time searching the forum before opening a new post :( :cry:

BTW in the Dictionary it says it works only for iOS, is there something similar for Android?

Regards,
Simon
________________________________________
To ";" or not to ";" that is the question

bwmilby
Posts: 439
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Mobile Sharing an Image via Whatsapp

Post by bwmilby » Wed Dec 19, 2018 12:48 am

No problem. I had an idea when I first saw the thread but it took me a bit to locate the correct command.

I think the URL direction is the way for Android. I’m not aware of an external, but with LCB it should be possible.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Wed Dec 19, 2018 12:54 am

Brian, not sure I understand what you mean by
...with LCB it should be possible
could you please clarify?

thanks
Simon
________________________________________
To ";" or not to ";" that is the question

bwmilby
Posts: 439
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Mobile Sharing an Image via Whatsapp

Post by bwmilby » Wed Dec 19, 2018 4:25 am

My guess is that there is an Android API that could be leveraged in the same way as the iOS external. Using the FFI capabilities of LCB a library could be built to allow access to those functions from LCS. See the Toast Notification Library as an example.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Mon Dec 24, 2018 7:31 pm

Thanks Brian, it seems too complicated to me (but I will have a look) compared with mergPopActivity which is really straightforward and works really well.

Regards
Simon
________________________________________
To ";" or not to ";" that is the question

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Mobile Sharing an Image via Whatsapp

Post by simon.schvartzman » Wed Feb 20, 2019 6:58 pm

For those readers interested in the subject please have a look at the following post

https://forums.livecode.com/viewtopic.php?f=53&t=32193

where you can see that the solution is much is really easy. Thanks Jacque!
Simon
________________________________________
To ";" or not to ";" that is the question

LucaJones
Posts: 3
Joined: Sat Jul 22, 2023 9:25 am
Location: Poland
Contact:

Re: Mobile Sharing an Image via Whatsapp

Post by LucaJones » Sat Jul 22, 2023 9:52 am

To enable image sharing via whatsapp in your app, you can use url schemes to open whatsapp with the image attached.
For ios, use whatsapp://send?text=&abid=IMAGE_URL and for android whatsapp://send?text=&image=IMAGE_URL replace IMAGE_URL with the image's url or path.
Hi, I am Luca

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Mobile Sharing an Image via Whatsapp

Post by stam » Tue Sep 12, 2023 12:40 pm

Do the posts above not answer your question?

Post Reply

Return to “Talking LiveCode”