await flutterLocalNotificationsPlugin.zonedSchedule( id, namazName, 'Namaz Alert', tz.TZDateTime.from(dateTime, pakistan), NotificationDetails( android: AndroidNotificationDetails( channel.id, channel.name, priority: Priority.high, color: primaryColor, icon: '#mipmap/ic_launcher', ) ), androidAllowWhileIdle: true, uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime, matchDateTimeComponents: DateTimeComponents.time, );have you find any solution for it to repeat local notification at a given time.
Related
I would like to add a button to my notification, I was able to get it displayed but I can't find the documentation on how to add an action to the button press
const androidNotification = AndroidNotificationDetails(
'Bla', 'Bla',
icon: 'ic_bg_service_small',
ongoing: true,
actions: [AndroidNotificationAction("stop", "Stop")]);
flutterLocalNotificationsPlugin.show(
888,
'MyService',
'bla',
const NotificationDetails(android: androidNotification),
);
You need to use this plugin to make action in notifications https://pub.dev/packages/awesome_notifications
void _showNotificationWithButton() {
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: 'Simple Notification',
body: 'Simple body'),
actionButtons: <NotificationActionButton>[
NotificationActionButton(key: 'yes', label: 'Yes'),
NotificationActionButton(key: 'no', label: 'No'),
],
);
}
the polyline is following the Route but it's not accurate only in long distances
this is short distance vs a long one
CLick here to see the image
i am using google_polyline_algorithm package to decode the response
i think the problem is in the request parameters
my code:
Dio dio = Dio();
List<LatLng> polyLineCoordinates = [];
final response = await dio.get(
"https://maps.googleapis.com/maps/api/directions/json?",
queryParameters: {
'origin':
'${myLocation.target.latitude},${myLocation.target.longitude}',
'destination':
'${orderLocation.target.latitude},${orderLocation.target.longitude}',
'key': "Google API Key",
'alternatives': 'false',
'travelMode':'DRIVE',
'optimizeWaypointOrder': false,
'polylineQuality': 'HIGH_QUALITY',
},
);
final lines = decodePolyline(
response.data["routes"][0]['overview_polyline']['points']);
lines.forEach((point) {
polyLineCoordinates
.add(LatLng(point[0].toDouble(), point[1].toDouble()));
});
widget code:
GoogleMap(
markers: {
Marker(
markerId: MarkerId('My Location'),
position: mapProvider.orderLocation.target,
icon: BitmapDescriptor.defaultMarker,
),
Marker(
markerId: MarkerId('Order Location'),
position: mapProvider.myLocation.target,
icon: BitmapDescriptor.defaultMarker,
),
Marker(
markerId: MarkerId('current Marker'),
position: mapProvider.currentLocaiton.target,
icon: BitmapDescriptor.defaultMarker,
)
},
polylines: {
Polyline(
// patterns: [
// PatternItem.
// ],
visible: true,
jointType: JointType.round,
geodesic: true,
endCap: Cap.roundCap,
startCap: Cap.roundCap,
polylineId: PolylineId("route"),
points: mapProvider.polyLineCoordinates,
color: Colors.blue
)
},
cameraTargetBounds: mapProvider.bounds!,
mapType: MapType.normal,
initialCameraPosition: mapProvider.orderLocation,
minMaxZoomPreference: MinMaxZoomPreference(10, 16),
onMapCreated: mapProvider.getCurrentLocation,
)
info:
Flutter version 3.0.1
google_maps_flutter: ^2.2.0
dio: ^4.0.6
google_polyline_algorithm: ^3.1.0
Apple pay button is showing in ios device
but google pay button is not showing in both the devices.
Here is my initPaymentSheet method
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
applePay: true,
googlePay: true,
testEnv: true,
merchantCountryCode: 'IN',
merchantDisplayName: 'DisplayName',
customerId: paymentIntentData!['customer'],
paymentIntentClientSecret: paymentIntentData!['client_secret'],
customerEphemeralKeySecret: paymentIntentData!['ephemeralKey'],
));
First Gpay App should be in your android device and second I think in iOS it will not support(2nd for iOS device I am not sure but till now in my implementation it's not working..)
Flutter version:
dependencies:
flutter_stripe: ^4.0.0
You Payment sheet code should be like this in latest way:
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
// Main params
paymentIntentClientSecret: data['paymentIntent'],
merchantDisplayName: 'Flutter Stripe Store Demo',
// Customer params
customerId: data['customer'],
customerEphemeralKeySecret: data['ephemeralKey'],
// Extra params
applePay: PaymentSheetApplePay(
merchantCountryCode: 'DE',
),
googlePay: PaymentSheetGooglePay(
merchantCountryCode: 'DE',
testEnv: true,
),
style: ThemeMode.dark,
appearance: PaymentSheetAppearance(
colors: PaymentSheetAppearanceColors(
background: Colors.lightBlue,
primary: Colors.blue,
componentBorder: Colors.red,
),
shapes: PaymentSheetShape(
borderWidth: 4,
shadow: PaymentSheetShadowParams(color: Colors.red),
),
primaryButton: PaymentSheetPrimaryButtonAppearance(
shapes: PaymentSheetPrimaryButtonShape(blurRadius: 8),
colors: PaymentSheetPrimaryButtonTheme(
light: PaymentSheetPrimaryButtonThemeColors(
background: Color.fromARGB(255, 231, 235, 30),
text: Color.fromARGB(255, 235, 92, 30),
border: Color.fromARGB(255, 235, 92, 30),
),
),
),
),
billingDetails: billingDetails,
),
);
i am lost at some point,
i am try to figure out how to use this plugin plugin here
what should use to reply this:
this is working on fcm fine but i am trying to switch from fcm because of the reply like whatsApp
FirebaseMessaging.onMessage.listen
FirebaseMessaging.onMessageOpenedApp.listen
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage message) {
});
you can use action button:
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: 'Action button title',
body: 'Simple body',
),
actionButtons: [
NotificationActionButton(
key: "REPLY",
label: "Reply",
autoCancel: true,
enabled: true,
buttonType: ActionButtonType.InputField,
icon: "resource://drawable/logo"),
],
);
I'm setting up flutter local notification, all is going well but i want to store the selected value in a text so if the app restart it will show selected value rather then resetting to default.
For example if I choose notification at 08:08:08 so after selecting it and restarting app whenever i go to notification selection time it should show 08:08:08(last selected value).
i have tried setstate(){};
but value always reset after restarting app.
here is my code.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:fluttertoast/fluttertoast.dart';
class SettingPage extends StatefulWidget {
#override
_SettingPage createState() => _SettingPage();
}
class _SettingPage extends State<SettingPage> {
///Flutter Local Notification
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
String notifyTime ="your time";
String nhour ="";
String nminutes ="";
String nseconds ="";
#override
initState() {
super.initState();
// initialise the plugin. app_icon needs to be a added as a drawable
resource to the Android head project
// If you have skipped STEP 3 then change app_icon to #mipmap/ic_launcher
var initializationSettingsAndroid =
new AndroidInitializationSettings('#mipmap/ic_launcher');
var initializationSettingsIOS = new IOSInitializationSettings();
var initializationSettings = new InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.initialize(initializationSettings);
}
Future _showNotificationWithDefaultSound() async {
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
importance: Importance.Max, priority: Priority.High);
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
'Learn Local Notification',
'A Local Notification On Button Click',
platformChannelSpecifics,
payload: 'Default_Sound',
);
}
Future scheuleAtParticularTime(DateTime timee) async {
var time = Time(timee.hour, timee.minute, timee.second);
print(time.toString());
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'repeatDailyAtTime channel id',
'repeatDailyAtTime channel name',
'repeatDailyAtTime description');
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
flutterLocalNotificationsPlugin.showDailyAtTime(0, 'Hey! Check your
today`s horoscope ',
'Login now to see your today`s horoscope !', time,
platformChannelSpecifics);
print('scheduled');
Fluttertoast.showToast(
msg:
"Notification Scheduled for ${time.hour} : ${time.minute} :
${time.second}",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
// also possible "TOP" and "CENTER"
backgroundColor: Colors.grey,
textColor: Colors.white);
setState(() {
nhour = time.hour.toString();
nminutes=time.minute.toString();
nseconds=time.second.toString();
notifyTime=nhour+" : "+nminutes+" : "+nseconds;
});
}
//function ends
#override
Widget build(BuildContext context) {
return Scaffold(backgroundColor: Theme.of(context).primaryColor,
appBar: AppBar(backgroundColor: Theme.of(context).primaryColor,
leading: IconButton(icon: Icon(FontAwesomeIcons.arrowLeft,
//backgroundColor: Theme.of(context).primaryColor,
), onPressed: () => {
Navigator.pop(context),}),
title: Text('Setting'),
),
body: Theme( data: Theme.of(context).copyWith(
canvasColor: Theme.of(context).primaryColor, //This will change the drawer background to blue.),
child: Center(
child: Container(
height: MediaQuery
.of(context)
.size
.height - 60.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 60.0),
child: RaisedButton(
color: Color(0xffffffff),
child: Text('Notification time - $notifyTime',////NEED TO STORE LAST VALUE HERE////////
style: TextStyle(
color: Color(0xff6200ee),
),),
onPressed: () {
DatePicker.showTimePicker(context, showTitleActions: true,
onChanged: (date) {
print('change $date');
}, onConfirm: (date) {
print('confirm $date');
scheuleAtParticularTime(
DateTime.fromMillisecondsSinceEpoch(
date.millisecondsSinceEpoch));
}, currentTime: DateTime.now(), locale: LocaleType.en);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
30.0),)
),
),
],),
),
);
}
}
you can use the shared_preferences plugin to store data on the device and use it in the app, even after it restarts.
First import the shared preferences plugin:
import 'package:shared_preferences/shared_preferences.dart';
To store data, simply do:
SharedPreferences prefs = await SharedPreferences.getInstance();
bool storedSuccessfully = await prefs.setString('<Your_Key>', <Your_String_Value>);
To get the stored data:
SharedPreferences prefs = await SharedPreferences.getInstance();
String storedValue = prefs.getString('<YOUR-KEY>');
So in your case, every time a user selects the value, you just have to store it with a key, and then every time the app restarts, simply fetch that value using the key you gave it, and use it.