Android Question Send more than one WhatsApp message

AlpVir

Well-Known Member
Licensed User
Longtime User
How to send the same WhatsApp message to 3 or 4 different contacts registered in a SQLite archive?
The following code sends only one message and forgets the others.
[CODE lang="b4x" ]
TxtWA="Lorem ipsum dolor sit amet, consectetur adipisci elit, sed do eiusmod"
rs=db.ExecQuery ("SELECT * FROM ....")
For i=0 To rs.RowCount-1
rs.Position=i
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, "https://api.whatsapp.com/send?phone=" & rs.GetString("Telefono") & "&text=" & TxtWA )
Intent1.SetComponent("android/com.android.internal.app.ResolverActivity")
StartActivity(Intent1)
Next
rs.close[/CODE]
 

AlpVir

Well-Known Member
Licensed User
Longtime User
It is a pity.
According to what you say it should be possible:
1) set the parameters for the first call
2) enter WhatsApp
3) press the WhatApp send button
4) exit WhatsApp (important)
5) set the parameters for the second call
6) enter into WhatsApp again
7) press the WhatApp send button
8) etc. etc.
I would also be willing to adopt such a solution, however cumbersome.
In fact, I'm surprised that the code I posted doesn't already do what I described.
 
Upvote 0

Mariano Ismael Castro

Active Member
Licensed User
You can take a look at that API, use WhatsApp Web to send messages and other things.


You can use my library, as for the demo project I am updating it
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
I downloaded the suggested library but it doesn't seem to be right for me as it seems intended to send a message to only one contact.
As a further difficulty I add that my app does not use B4X Pages.
Could you check if it is really possible to achieve what you want using the library in question ?
 

Attachments

  • Screenshot_20240615_182610.jpg
    160.4 KB · Views: 107
Upvote 0

Mariano Ismael Castro

Active Member
Licensed User
I'm going to prepare a basic example and share it with you.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
It appears to me that there is only one version of the library, the "1".
It also turns out that you have to call that library with
greenApi.Initialize(Me,"GreenApi",myIdInstance,myApiTokenInstance)
and not with
greenApi.Initialize(Me, "GreenApi", myIdInstance,myApiTokenInstance , xui.DefaultFolder)
Having said this, it seems to me that the library is not for me because, if I have understood correctly, it requires that each user of the app in which this library is implemented must register their WhatsApp number. And this would be too complicated for users of my app.
In any case I tried your code and the result is negative.
This is the log
The only changes to your code were
greenApi.Initialize(Me,"GreenApi",myIdInstance,myApiTokenInstance)
And
For Each WhatsAppNumber As String In Array("+39348xxxxxxx")
My app is "SONO QUI" but I don't know if it is available outside of Italy.
You simply have to send a certain text to 3 or 4 (no more) WhatsApp contacts within a few minutes.
Thanks for your patience
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…