Android Question Send PDF via Whatsapp - Number not in Contacts

Setlodi

Active Member
Hi Friends

I send PDF receipts via WhatsApp business to customers. The issue is when I send to phone numbers that's in my contact list it works fine. However, when I send to phone numbers that are not in my contacts it opens installed WhatsApp and wants me to select a contact from my list before I send.

Here is my code:
B4X:
Sub sharePDFToViaWs(afile As String, toNumber As String)
    Dim in As Intent
    in.Initialize(in.ACTION_MAIN,"")
    fFileProvider.SetFileUriAsIntentData(in, afile)
    in.Action=in.ACTION_SEND
    in.SetPackage("com.whatsapp.w4b")
    in.PutExtra("android.intent.extra.STREAM", fFileProvider.GetFileUri(afile))
    in.PutExtra("jid", "27" & toNumber & "@s.whatsapp.net")
    in.putExtra("android.intent.extra.TEXT", "Testing")
    in.SetType("application/pdf")
    StartActivity(in)
End Sub

Private Sub btnSendWhatsapp_Click
    Dim PhoneNumber As String = txtWA_Phone_Number.Text
    Dim Formatted_Phone_Number As Int = NumberFormat2(PhoneNumber,0,0,0,False)
    Log("Formatted_Phone_Number = "&NumberFormat2(Formatted_Phone_Number,0,0,0,False))
    sharePDFToViaWs(Receipt_File_Name, Formatted_Phone_Number)
    pnlReceiptWhatsapp.Visible = False
End Sub

I'm stuck here. Please help.
 
Solution
save the contact in your address book before sending the whatsapp

Thank you so much Lucas. I'll work on it!

Lucas Siqueira

Active Member
Licensed User
Longtime User
save the contact in your address book before sending the whatsapp

 
Upvote 0

Setlodi

Active Member
save the contact in your address book before sending the whatsapp

Thank you so much Lucas. I'll work on it!
 
Upvote 0
Solution
Top