I'm trying to send a message to multiple phone numbers via WhatsApp using Flutter:
sendMessage() async {
var number = ["201020402642", "201030666895"];
var baseUrl = "https://api.whatsapp.com/send/";
var urlIos = "";
number.forEach((element) async {
var url = baseUrl +"?phone=${element} &text=msg";
if (await canLaunch(url)) {
await launch(url);
} else {
print("not installed");
}
});
}
It only sends a message to the last number.
Is there a way to send a message to a group of numbers?
Unfortunately, there's no way to send a message for more than 1 number at the same time using deep links. The only way you can do something like this is by using the WhatsApp business API through REST requests. There are some third-party software with this feature like https://www.twilio.com/whatsapp
Here is the WhatsApp API doc
https://developers.facebook.com/docs/whatsapp/api/messages/#sending-messages
Related
clientViaUserConsent opens URL in browser but it said invalid request. this URL is generated internally from lib. I had double-checked my ClientId for both platforms but still face issues for getting AuthClient for create a calendar event.
I used the below packages to create events in the google calender.
googleapis: ^8.1.0
googleapis_auth: ^1.3.0
static final androidClientId = ClientId('xxxxxxxx.apps.googleusercontent.com');
static final iOSClientId = ClientId('xxxxxxx.apps.googleusercontent.com');
final _clientID = Platform.isAndroid ? EventProvider.androidClientId : EventProvider.iOSClientId;
final _scopes = [CalendarApi.calendarScope];
clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient client) {
var calendar = CalendarApi(client);
}
void prompt(String url) async {
print(" => $url");
if (await canLaunch(url)) {
await launch(URL);
} else {
throw 'Could not launch $url';
}
}
I am referring to this article for creating an event in google calendar.
https://blog.codemagic.io/google-meet-events-in-flutter/
https://medium.com/flutter-community/flutter-use-google-calendar-api-adding-the-events-to-calendar-3d8fcb008493
You are seeing that error because the app hasn't been verified. If you are the app developer I advise you to check the App Verification FAQ to learn more about the verification steps. If you aren't the developer, you could try to enable the less secure app access but please be mindful of the consequences:
Less secure apps can make it easier for hackers to get in to your account, so blocking sign-ins from these apps helps keep your account safe.
I am building an flutter web application that has to be able to send message on specific WhatsApp Business number and WhatsApp number. What exactly am I supposed to do? If the user's device has either WhatsApp or WhatsApp Business, he opens it. But my problem is that if user's device has both WhatsApp and WhatsApp business, I want one to open on one condition.
var whatsappURlAndroid = "https://wa.me/$whatsappNumber/?text=Hi";
var whatappURLIos ="https://wa.me/$whatsappNumber?text=${Uri.parse("hello")}";
var webWhatsapp= "https://web.whatsapp.com/send?phone=$whatsappNumber&text=Hello";
if (defaultTargetPlatform == TargetPlatform.iOS) {
await launch(whatappURLIos, forceSafariVC: false);
}else if(defaultTargetPlatform == TargetPlatform.android){
await launch(whatsappURlAndroid);
}
else{
await launch(webWhatsapp);
}
FocusManager.instance.primaryFocus?.unfocus();
var whatsappUrl = "whatsapp://send?phone=${_countryCodeController.text +
_phoneController.text}" +
"&text=${Uri.encodeComponent(_messageController.text)}";
try {
launch(whatsappUrl);
} catch (e) {
// To handle error and display error message:
Helper.errorSnackBar(
context: context, message: "Unable to open whatsapp");
}
I am creating an application in Flutter Web that needs to collect payment information to create subscription charges. My plan was to use Stripe to do this, however, after making all the necessary methods for Stripe, I found that Stripe only accepts card data through Stripe Elements. Upon further research, I saw that essentially all payment platforms do this to maintain PCI compliance.
Is there any method of embedding Stripe elements(or any equivalent) into my application or is there an easier method of accepting payments with Flutter Web?
There's an unofficial Flutter Stripe package that might be what you're after: https://pub.dev/packages/stripe_payment
There's a new package called stripe_sdk, that appears to have Web support. I haven't tried it yet, but it says Web support in the description and has a web demo aswell :)
Also the old packages for mobile won't work for web, because they rely on WebView, which is not supported (and wouldn't make much sense) on web.
In case you're using Firebase as a backend, there's a stripe payments extension you can install in Firebase which makes it easy. How it works is you add a checkout_session in to a user collection and keep listening on the document. Stripe extension will update the document with a unique payments url and we just open that URL in a new tab to make the payment in the tab. We're using it in our web app, and it's working.
Something like :
buyProduct(Product pd) async {
setState(() {
loadingPayment = true;
});
String userUid = FirebaseAuth.instance.currentUser!.uid;
var docRef = await FirebaseFirestore.instance
.collection('users')
.doc(userUid)
.collection('checkout_sessions')
.add({
'price': pd.priceId,
'quantity': pd.quantity,
'mode': 'payment',
'success_url': 'https://yourwebsite/purchase-complete',
'cancel_url': 'https://yourwebsite/payment-cancelled',
});
docRef.snapshots().listen(
(ds) async {
if (ds.exists) {
//check any error
var error;
try {
error = ds.get('error');
} catch (e) {
error = null;
}
if (error != null) {
print(error);
} else {
String url = ds.data()!.containsKey('url') ? ds.get('url') : '';
if (url != '') {
//open the url in a new tab
if (!isStripeUrlOpen) {
isStripeUrlOpen = true;
setState(
() {
loadingPayment = false;
},
);
launchUrl(Uri.parse(url));
}
}
}
}
}
},
);
}
I'm building a Flutter app and I want users to be able to login through Steam (OpenId).
The app is powered by Firebase.
I'm pretty new to the whole OpenId world and I've read into it but I'm still not getting it.
I found that Firebase Supports signinWithCustomToken so I think I should get the Steam OpenId to get me one of those.
I also found two packages which might help me but I couldn't get those to work either:
https://pub.dev/packages/openid_client
https://pub.dev/packages/steam_login
If tried the following sample from the openid_client package:
_authenticate(Uri uri, String clientId, List<String> scopes) async {
try {
var issuer = await Issuer.discover(uri);
var client = Client(issuer, clientId);
print('CLAIMS:');
print(issuer.claimsMap);
urlLauncher(String url) async {
if (await canLaunch(url)) {
await launch(url, forceWebView: true);
} else {
throw 'Could not launch $url';
}
}
var authenticator = Authenticator(client,
scopes: scopes, port: 4000, urlLancher: urlLauncher);
var c = await authenticator.authorize();
closeWebView();
print(await c.getUserInfo());
}catch (err) {
print(err);
}
}
But I have no idea what to give as the uri, clientId and scopes.
For the uri I've tried https://steamcommunity.com/openid but when I try this I'm getting an error that it tried to Json.parse a xml response.
I've also tried the example for the steam_login package here, but that does nothing and doesn't feel like it should work within a Flutter app (even though the package states it Flutter compatible).
So if anybody could explain to me how I could achieve this with a working sample that would be great.
If I get this to work I'm planning on creating a tutorial/guide for it for others.
I want to send email directly to admin email without opening gmail application through URL package in flutter URL package work perfectly but that is not required. I want to do it through fire-base where I also want to save all data send to admin email. I need to know the email function of firebase or any such function that help me to send direct email.
_launchURL(String toMailId, String subject, String body) async {
var url = 'mailto:$toMailId?subject=$subject&body=$body';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}