Page 1 of 1
Send link with WhatsApp
Posted: Thu Dec 31, 2020 2:28 pm
by trevix
LC 9.6.2
I've been trying to send a text link to WhatsApp, from iPhone and Android, using my LC App.
Code: Select all
on mouseUp
--this is the text: <p>Ciao.</p><p><a href="https://www.segnapunto.it/">This is my link: www.segnapunto.it</a></p>
put "<p>Ciao.</p><p><a href=" & quote & "https://www.segnapunto.it/" & quote & ">This is my link: www.segnapunto.it</a></p>" into tText
if the environment = "mobile" then
try
mobileComposeHtmlMail "TestInvito",,,,tText
catch errorParameter
answer errorParameter
end try
if the Platform <> "android" then --android does not return anything
answer the result
end if
end if
end mouseUp
Both using "mobileComposeHtmlMail" or "mobileComposeMail", on Android I get the dialog, where if I chose email, it works fine but if I chose WhatsApp nothing happens.
The only time it works with WhatsApp is if i add an attachment. But no text from the "body" get displayed.
I also tried to pu "whatsapp" on the Custom Url scheme of the Android standalone settings.
Is there something that I should know?
Thanks
Re: Send link with WhatsApp
Posted: Fri Jan 01, 2021 3:51 pm
by simon.schvartzman
Hi Trevix, teh code below is the one I use on one of my Apps to open the Share options (including WhatsApp) on both Android and iPhone.
I guess you can try/customize it with your data.
Code: Select all
try
if the platform is "iPhone" then
-- it is so easy on iPhone!!!
put specialfolderpath("documents") & "/" & "spot.png" into tPath
export snapshot from group "Group 1" of card "Capture" with metadata theMetadataArray to file tPath as PNG
mergPopActivity "",tPath,"",""
if the result is "mergPopActivity: cancel" then
exit to top
end if
else
export snapshot from group "Group 1" of card "Capture" to image "AuxImg" as JPEG
put image "AuxImg" into tAttachment["data"]
put "image/jpg" into tAttachment["type"]
put "LuckroSpot" into tAttachment["name"]
mobileComposeMail "Imagem capturada com LuckroSpot", ,,,, tAttachment
-- next statement is needed due to Android bug (I guess is a bug)
set the fullscreenmode of this stack to "showAll"
end if
catch e
answer e
end try
Hope it helps
Re: Send link with WhatsApp
Posted: Fri Jan 01, 2021 4:30 pm
by trevix
i think I did not explain my problem, that concerns only Android:
My goal is to give the user the chance to send a precompiled text with URL, both for Email and WhatsApp (very popular).
On Android,for WhatsApp, unless I put an attachment, LC mobileComposeMail (or mobileComposeHtmlMail) does not fire WhatsApp. Even then, no text appear, only the attachment.
Anyway I found a way:
Code: Select all
--if WhatsApp
put "Go here: http://www.segnapunto.it" into tText
put URLEncode(tText) into tText
put "whatsapp://send?text=" & tText into theURL
launch url theURL
--if Email
PUT "<p>Go here: <br></p><a href=" & quote & "https://www.segnapunto.it" & quote && "rel=" & quote & "self" & quote & ">www.segnapunto.it</a></span>" into tText
mobileComposeHtmlMail "SegnaPunto: Buono regalo", ,,, tText
---"New problem"
My "New problem" is that even asking to the user if he wants WhatsApp or Email, when he chose email, mobileComposeHtmlMail still show the OS windows where to chose how to share (mai,gMail, whatsapp,...). I don't understand why and how to force Email only (but with a html link).
Re: Send link with WhatsApp
Posted: Sat Jan 02, 2021 12:21 pm
by simon.schvartzman
Hi Trevix, I had this problem before, please have a look at this post
viewtopic.php?f=53&t=32193 .
As you can see what you are getting is the expected result in Android, I'm sorry to say it is not what you would like to have but this is the way it is...
Re: Send link with WhatsApp
Posted: Sat Jan 02, 2021 12:58 pm
by trevix
In that post Jacque wrote:
...If the user has selected a default app for the file type then the picker won't be displayed at all, the default app will open instead....
I wonder then, how can i select a default app for the file type, inside "mobileComposeMail", so as to force on Android the MailApp or whatsApp?
"set the fileType to creator & type" should do, but has WhatsApp a "creator & type"? What about Email (user could have, other app then the default Email program.
Will have to do some testing.
Any suggestion?
Re: Send link with WhatsApp
Posted: Sat Jan 02, 2021 1:11 pm
by simon.schvartzman
As far as I understand it the default App for the file type is to be selected on the device itself not on the LC environment.
You can try it following this instructions:
https://www.androidauthority.com/change ... -2-633572/
Re: Send link with WhatsApp
Posted: Sat Jan 02, 2021 7:20 pm
by jacque
The default app is a system-wide setting chosen by the user and can't be changed per app or by script. In fact, most users will already have a default app set, though I go out of my way to avoid that because I want to choose the app each time. If you were able to reset the user's default choice you'd have some pretty angry users.
I think the default app depends on the file extension. Creator and type codes were only for Mac OS 9 and are obsolete now.
Re: Send link with WhatsApp
Posted: Sun Jan 03, 2021 1:42 pm
by simon.schvartzman
Trevix, if instead of WhatsApp a text message (SMS) is acceptable to you an option to acomplish your goal would be to send the message to a server and then have a script to forward it through SMS (I guess it could be done with WhatsApp as well but is more complex than pure SMS)...
Just and idea
Re: Send link with WhatsApp
Posted: Sun Jan 03, 2021 4:44 pm
by trevix
In italy nobody uses sms anymore. Only security check (ha ha)
Re: Send link with WhatsApp
Posted: Sat Jul 22, 2023 10:07 am
by LucaJones
The issue you are facing is that despite giving the user the option to choose between whatsapp and email, the 'mobilecomposehtmlmail' function on android still shows the os window to select how to share, offering choices like gmail and whatsapp.
You want to force the email option but still use an html link. Unfortunately, without more control over the sharing behavior, it might not be possible to bypass the os window and directly send an html link via email.
Consider exploring alternative approaches, that offer more customization options for handling email functionality on android.
Re: Send link with WhatsApp
Posted: Tue Jan 09, 2024 6:00 am
by FourthWorld
qoumsel wrote: ↑Tue Jan 09, 2024 3:34 am
There are a few things you can consider to troubleshoot the issue:
Hi qoumsel. I'm curious, what was it about half-year old thread that compelled you to create an account here to reply to it?