Mobile Sharing an Image via Whatsapp
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Mobile Sharing an Image via Whatsapp
Hi, I was asked to develop an App (iOS and Android) that should be able to share an image via Whatsapp.
I know how to handle the image capture part of the App but I'm not aware of any functionality that could be used on LC to deliver the Whatsapp sharing functionality.
Any ideas?
Many thanks
I know how to handle the image capture part of the App but I'm not aware of any functionality that could be used on LC to deliver the Whatsapp sharing functionality.
Any ideas?
Many thanks
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Mobile Sharing an Image via Whatsapp
UrlSchemes were cross platform, and still the go-to mechanism for inter-app stuff on Android. Apple was pushing for an alternative, and may still be, but check their docs as UrlSchemes may still be well supported.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
Thanks @FourthWorld your suggestion sounds promising.
I did some search on WhatsApp FAQ and found the following:
Best!
I did some search on WhatsApp FAQ and found the following:
which seems to be the way to go and I wonder if there is any LC support for such "Share Extension". Wasn't able to find any mention to it on the documentation.Share Extension
Introduced in iOS 8.0, Share Extension provides a convenient way for any app to share content with other applications installed on user's iPhone. This is now the preferred way of sharing your content onto WhatsApp. This is as simple as creating an instance of UIActivityViewController and presenting it in your app. WhatsApp accepts the following types of content:
Best!
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Mobile Sharing an Image via Whatsapp
It seems WhatsApp also supports a urlScheme:
https://faq.whatsapp.com/en/iphone/23559013
https://faq.whatsapp.com/en/iphone/23559013
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
@FourthWorld in fact the quote I added on my previous post was taken from the same link your are referencing.
But when I run
I get
If I insert the same URL on my WebBrowser (both iPhone and desktop) the WhatsApp picking contact window opens as expected.
Not sure what am I doing wrong, have to do more testings...
But when I run
Code: Select all
put "whatsapp://send?text=Hello%2C%20World!" into theURL
put URL theURL into temp
answer the result
It happens both on the iPhone and in the desktop.Invalid URL: "whatsapp://send?text=Hello%2C%20World!"
If I insert the same URL on my WebBrowser (both iPhone and desktop) the WhatsApp picking contact window opens as expected.
Not sure what am I doing wrong, have to do more testings...
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
Made some progress. The following code works fine on the desktop
but gives the following error on the iPhone
Thanks
Code: Select all
put "whatsapp://send?text=Hello%2C%20World!" into theURL
launch url theURL
answer the result
Any hints to fix the error?no association
Thanks
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Mobile Sharing an Image via Whatsapp
Erm, well, the biggest problem might be that 'launch' isn't made for mobile.
Lc Dictionary wrote: launch
type
command
syntax
launch [documentPath with] applicationPath
summary
Starts up an application, optionally opening a document in the application.
introduced
1.0
OS
mac, windows, linux
platforms
desktop, server
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
@bogs, thanks for your input but unless I'm missing something this is not my problem because I'm using "launch url" which is supposed to work on mobile as well
Is there anything I'm not seeing?
Is there anything I'm not seeing?
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Mobile Sharing an Image via Whatsapp
Nope, case of blindness on my part I'd say
I should add I don't do any mobile programming as well. If I had to guess (which I would ) I'd guess that the url isn't properly associated on the mobile device with another program.
A test *might* be changing -
Code: Select all
put "whatsapp://send?text=Hello%2C%20World!" into theURL
Code: Select all
put "https://www.duckduckgo.com" into theURL
If that is the case, then you know the code your using is correct, and the address isn't associated properly on mobile becomes more likely. Least, that is what I would do. IF that doesn't work, I'm afraid you'll have to wait for someone that knows what they are talking about
*Edit - you might also add 'answer the result' with your original code to see what spits up on the mobile device (possibly effective, don't know the limits on mobile). According to the dictionary -
value
Name Type Description
the result
When launch url is called, LiveCode checks to see if an application is available to handle the URL. If no such application exists, the command returns "no association" in the result.
One other thing that is jumping out for me is the string your using in the address posted here
Code: Select all
text=Hello%2C%20World!"
Yes, I know it works on the desktop, but I've seen wierder stuff. Of course, it could be completely correct as well, I didn't take time to look it up
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
@bogs many thanks for your suggestions, here I go
works fine.
gave the same "no association" error as was giving with "2C" instead of "20" (nice catch)
regarding
and this is where I get the "no association" error on the mobile.
Anyone from LC there to clarify what can be done?
Code: Select all
put "http://www.livecode.com" into the URL
Code: Select all
put "WhatsApp://send?text=Hello%20%20World!" into theURL
regarding
I already have it on my code*Edit - you might also add 'answer the result' with your original code to see what spits up on the mobile device (possibly effective, don't know the limits on mobile)
Code: Select all
on mouseUp
put "WhatsApp://send?text=Hello%20%20World!" into theURL
--put "http://www.livecode.com" into theURL
launch url theURL
answer the result
end mouseUp
Anyone from LC there to clarify what can be done?
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Mobile Sharing an Image via Whatsapp
Isn't '%20' the url code for a space? If so, may want to eliminate one of those 2.simon.schvartzman wrote: ↑Mon Dec 17, 2018 3:33 pm[put "WhatsApp://send?text=Hello%20%20World!" into theURL]
gave the same "no association" error as was giving with "2C" instead of "20"
No association I am pretty sure means that the device doesn't have an associated program to handle whatsapp addresses, which would explain why it works on the desktop (but you already know this, I am merely thinking aloud as it were at this point).
I'm not sure that is something Lc can do anything about, as Lc polls the underlying OS for the associations.
For instance, I don't have whatsapp installed on, well, anything here. When I run your code, obviously nothing shows up since there is no association to whatsapp on the machine (desktop).
Lc can't fix something like the above, obviously. I assume your installation on the mobile device is the default way to go with whatsapp, barring rooting your phone or getting the apk from some other source or whatever.
If the mobile device did not make the whatsapp association properly, or if whatsapp itself doesn't do it properly on the device, that can be a sticky thing to resolve.
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
In my last try I got rid of the "spaces" and used
and still no joy, same error.
You are correct about
and I would assume a similar functionality should be able to be delivered on an LC developed App. Don't you think so?
Code: Select all
put "WhatsApp://send?text=Hello-World!" into theURL
You are correct about
and as a matter of fact I'm able to share through whatsapp from many Apps installed on my phone using the familiar share screen:I assume your installation on the mobile device is the default way to go with whatsapp..."
and I would assume a similar functionality should be able to be delivered on an LC developed App. Don't you think so?
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Mobile Sharing an Image via Whatsapp
Oh, I didn't think that having 2 spaces in the 'hello world' thing was messing it up, I was just thinking about dropping unnecessary things from the url that might lessen the complication.In my last try I got rid of the "spaces" and used
and still no joy, same error.Code: Select all
put "WhatsApp://send?text=Hello-World!" into theURL
Sorry for any confusion
simon.schvartzman wrote: ↑Mon Dec 17, 2018 4:11 pmas a matter of fact I'm able to share through whatsapp from many Apps installed on my phone using the familiar share screen:
Well, that screen may be familiar to you, but it is my first time seeing itand I would assume a similar functionality should be able to be delivered on an LC developed App. Don't you think so?
The complete amount of gross ignorance I have with mobile is... well... complete. I have no idea what 'AirDrop' is, or how iOs does things in general.
Proceeding from my abysmal lack of knowledge, the picture (to me) looks like some kind of interpreter screen if you will, where you are picking the 'output' of some program, then using this screen to 'send' it to some other program (like whatsapp, mail, or facebook).
If that is the case (again, I don't know), then this 'AirDrop' is making the association for you for the particular program(s) you are 'sharing' through whatsapp, not because of some underlying association in the iOs OS, if you see the difference.
I am curious, though, if you can indeed add your Lc program to the list of AirDrops associated programs? Or alternately, if you couldn't take some form of output from your Lc program and use AirDrop to make the association for you?
Sorry, that is about as far as I can figure it with what I don't know, which is a LOT.
To answer your question specifically on something I *think* I know about, no, and your own testing should validate that.
The reason it 'works' fine is because iOs has actual web addresses associated with opening a browser. It (iOs) just doesn't understand opening 'whatsapp' addresses, because apparently there is no association with that string.
Now, if there is a way for you to create such an association (I have no idea), then that would be the way to go.
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Mobile Sharing an Image via Whatsapp
@bogs FYI English is not my mother tongue and therefore I could mislead you (and other readers) due to poor writing skills.
Having say so let me see if I can clarify some of your remarks
Will see how the story ends up. Still waiting for some of the LC gurus to jump in.
Cheers
Having say so let me see if I can clarify some of your remarks
Airdrop is just an Apple peer to peer communication scheme where both devices are close to each other (i.e. bluetooth distance)I have no idea what 'AirDrop' is,
You got it, that's exactly what it is aboutwhere you are picking the 'output' of some program, then using this screen to 'send' it to some other program (like whatsapp, mail, or facebook).
In my humble opinion AirDrop has nothing to do with it. It is just another way to share stuff....then this 'AirDrop' is making the association for you...
That's not the ideaI am curious, though, if you can indeed add your Lc program to the list of AirDrops associated programs?
That's the idea (without the AirDrop part...)Or alternately, if you couldn't take some form of output from your Lc program and use AirDrop to make the association for you?
Will see how the story ends up. Still waiting for some of the LC gurus to jump in.
Cheers
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Mobile Sharing an Image via Whatsapp
I'd never have guessed, glad you clarified.simon.schvartzman wrote: ↑Mon Dec 17, 2018 8:29 pm@bogs FYI English is not my mother tongue and therefore I could mislead you (and other readers) due to poor writing skills.
Dunno, I can only go by what I see on the screen. To me, it looks like you have a set of programs to send (what looks like) something you brought into AirDrop. I'll take your word that it doesn't work that way, I sure have no experiences to say otherwisesimon.schvartzman wrote: ↑Mon Dec 17, 2018 8:29 pmYou got it, that's exactly what it is aboutIn my humble opinion AirDrop has nothing to do with it. It is just another way to share stuff....then this 'AirDrop' is making the association for you...
Just out of curiousity, what happens when you enter the whatsapp address into the address bar of the web browser on the device? It is possible, I suppose, that the web browser could be a big enough fish for the 'share extension' you were talking about to pick the address out of the address bar, but I would be curious to know.
Since the only remaining things I can think of would be setting the association (dunno how), or if iOs had a version of the shell out (answer is no, according to the dictionary), or if someone knows how to direct a mobile program to directly launch another mobile program.
Good luck is all I can say at this point, maybe if we pray hard enough, Jacque will pop in with some magic. I'll start praying for you now...