Closed ghost closed 4 years ago
Do you want to go to google play or what?
Do you want to go to google play or what?
just look for WhatsappBusiness if Whatsapp is not installed,if both are not installed just Show whatapp is not installed thats enoguh for a user
Modifiyng the lib file to the following adds support to Whatsapp Business app.
Future<String> shareToWhatsApp(
{String msg = '', String base64Image = ''}) async {
final Map<String, Object> arguments = Map<String, dynamic>();
arguments.putIfAbsent('msg', () => msg);
arguments.putIfAbsent('url', () => base64Image);
dynamic result;
try {
result = await _channel.invokeMethod('shareWhatsApp', arguments);
} catch (e) {
result = "NoWhatsApp";
}
if (result=="NoWhatsApp") {
try {
result = await _channel.invokeMethod('shareWhatsApp4Biz', arguments);
} catch (e) {
result = "NoWhatsApp4Biz";
}
}
return result;
}
//Update the following in flutter_share_me-0.6.0\android\src\main\java\zhuoyuan\li\fluttershareme
//....
case "shareWhatsApp":
msg = call.argument("msg");
url = call.argument("url");
shareWhatsApp(url, msg, result);
break;
case "shareWhatsApp4Biz":
msg = call.argument("msg");
url = call.argument("url");
shareWhatsApp4Biz(url, msg, result);
break;
////
//then include the below code at the end
private void shareWhatsApp4Biz(String url, String msg, Result result) {
try {
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp.w4b");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, msg);
if (!TextUtils.isEmpty(url)) {
FileUtil fileHelper = new FileUtil(registrar, url);
if (fileHelper.isFile()) {
whatsappIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
whatsappIntent.putExtra(Intent.EXTRA_STREAM, fileHelper.getUri());
whatsappIntent.setType(fileHelper.getType());
}
}
whatsappIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.startActivity(whatsappIntent);
result.success("success");
} catch (Exception var9) {
result.error("error", var9.toString(), "");
}
}
Example Usage:
void sharetoWhatsapp(){
String resultis = await FlutterShareMe().shareToWhatsApp(base64Image: base64string,msg: "text");
if (resultis == 'NoWhatsApp4Biz') {
print('WHATSAPP & WHATSAPP 4 BUSINESS BOTH APPS NOT INSTALLED');
}
}
I don't know anything about native android or services.Just it works thats all i know,pls correct the code and update the plugin.
I will try this code Oh My God! "Whatsapp Business" turned out to be an App , I didn't know this application before.
I will try this code Oh My God! "Whatsapp Business" turned out to be an App , I didn't know this application before.
So thats why u confused at the very first time I asked right? No pblm update it
if Whatsapp is not installed,pls open whatsapp biz feature