whatsapp 1.0.1 whatsapp: ^1.0.1 copied to clipboard
A package for whatsapp business api, send messages, product, media, location through flutter app.
WhatsApp Business Configuration #
You must have WhatsApp apps in facebook developer, to use this package, please follow this link for Guidence.
Installation #
import 'package:whatsapp/whatsapp.dart';
Whatsapp whatsapp = Whatsapp();
Configure access_token and Phone ID
whatsapp.setup(
access_token: "your_access_token_here",
phone_numner: "your_business_number_id"
);
💬 short Direct chat link
this method used to generate direct chat link
parameter:-
to
- number of clientmessage
- messagecompress
- true / false for compress link
sample code:-
whatsapp.short(
to: "910000000000", // number with country code (without +),
message: "Hey", //template name
compress: true
);
💬 messagesTemplate Send a template message
this method used to send a template message to client's whatsapp
parameter:-
to
- number of clienttemplate_name
- name of a template
sample code:-
whatsapp.messagesTemplate(
to: "910000000000", // number with country code (without +),
template_name: "hello_world" //template name
);
💬 messagesText Send a text message
this method used to send a text message to client's whatsapp
parameter:-
to
- number of clientmessage
- message your want to sendpreview_url
- true and false for preview url in message
sample code:-
whatsapp.messagesTemplate(
to: "910000000000", // number with country code (without +),
message: "Hey, Flutter, follow me on https://example.com", //message
preview_url: true
);
💬 messagesMedia Send a media message
this method used to send a media message to client's whatsapp
parameter:-
to
- number of clientmedia_type
- type of media ex. imagemedia_id
- uploaded media id on whatsapp business sample code:-
whatsapp.messagesMedia(
to: "910000000000", // number with country code (without +),
media_type: "image",
media_id: "f043afd0-f0ae-4b9c-ab3d-696fb4c8cd68"
);
💬 messagesLocation Send a location message
this method used to send a location message to client's whatsapp
parameter:-
to
- number of clientlongitude
-longitude stringlatitude
- latitude stringname
- name of locationaddress
- full address of location
sample code:-
whatsapp.messagesMedia(
to: "910000000000", // number with country code (without +),
longitude: "26.4866491",
latitude: "74.5288578",
name: "Pushkar",
address: "Rajasthan, India"
);