I am using flutter and developing a reminder app. I want to insert database after then notification created. These codes run the emulator. After installing the application on the real device, it does not insert. what could be the reason?
I call function IconButton pressed.
createOrganizerNotification(
taskName, time, taskDate, nt, sm, taskIcon);
And I create notification(success) and call insert table function.
void createOrganizerNotification(var taskName, var taskTime, var taskDate,
var notificationTitle, var seeMore, var taskIcon) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
var email = preferences.getString("usermail");
var time = taskTime.split(':');
var date = taskDate.split('-');
taskIcon = taskIcon.split('"');
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: createUniqueId(),
channelKey: 'notification_channel',
title: notificationTitle,
body: taskDate + ' - ' + taskTime + ' - ' + taskName,
),
/*actionButtons: [
NotificationActionButton(
key: 'see_more',
label: seeMore,
)
],*/
schedule: NotificationCalendar(
day: int.parse(date[0]),
month: int.parse(date[1]),
year: int.parse(date[2]),
hour: int.parse(time[0]),
minute: int.parse(time[1])));
await DBHelper().insertOrganizerNotification(
email,
date[0].toString(),
date[1].toString(),
date[2].toString(),
time[0].toString(),
time[1].toString(),
taskName.toString(),
'created',
taskIcon[1].toString());
}
This is insert to database function.
Future<bool> insertOrganizerNotification(
String email,
String day,
String month,
String year,
String hour,
String minute,
String title,
String status,
String icon,
) async {
try {
final conn = await MySqlConnection.connect(
ConnectionSettings(
host: _host,
port: _port,
user: _user,
password: _password,
db: _db),
);
await conn.query(
'insert into OrganizerNotificaitonsList ( Email, Day, Month, Year, Hour, Minute, Title, Status, Icon ) values ( ?,?,?,?,?,?,?,?,?)',
[email, day, month, year, hour, minute, title, status, icon]);
await conn.close();
return true;
} catch (e) {
return false;
}
}
And this is my table structure.

Really I don't understand this bug. Because the emulator can insert the database successfully. Only real devices have this bug.