rohitsangwan01 / whatsapp_bot_flutter

Whatsapp bot for flutter desktop
MIT License
41 stars 27 forks source link

Send PDF file - file will not display on iOS WhatsApp app #21

Closed arytbk closed 1 year ago

arytbk commented 1 year ago

When I try to send a PDF file using chat.sendFileMessage and fileType: WhatsappFileType.document the received file on WhatsApp iPhone will show as "application.pdf" but if I click to open it will show a blank screen, and written in the middle: "application.pdf - Microsoft Word 97-2004 document"

patricknicolosi commented 1 year ago

@arytbk Currently, only sending word, jpeg or mp3 files should be supported @rohitsangwan01 This is probably a mime type error https://github.com/rohitsangwan01/whatsapp_bot_flutter/blob/369fc08211812373267742219dd3f58187704205/packages/whatsapp_bot_platform_interface/lib/src/helper/utils.dart#L103 It might be useful to go to myme_type for a more correct definition of myme tipe.

I did a similar thing with my package https://github.com/patricknicolosi/whatsapp_sender_flutter/blob/efeb4405efd8fecc0d71bbcef74e9341b6eb2d05/lib/src/whatsapp_sender_flutter.dart#L112

The fileType parameter is not necessary

arytbk commented 1 year ago

Thanks, that's it! With mimeType "application/pdf" it works fine.

Now I just miss a way to define the file name that appears in WhatsApp, it seems to be hard coded from the mimeType as: fileTypeName = mimeType.split("/").first;

It would be nice to add a fileName parameter (optional) that would be used if present.

rohitsangwan01 commented 1 year ago

@arytbk @patricknicolosi thanks for the suggestions , i will implement a proper way to handle this

rohitsangwan01 commented 1 year ago

Fixed in https://github.com/rohitsangwan01/whatsapp_bot_flutter/pull/28