Commit 7aaf5cbc authored by Indika NK's avatar Indika NK

Awareness level related changes

parent 4d634207
import 'dart:ffi';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:oktoast/oktoast.dart';
......@@ -19,6 +20,52 @@ class NotificationPlugin {
int awarenessLevel = 0;
//getting awareness from Users Collection
getAwareness() async{
print("Executing get data");
final CollectionReference userlist =
FirebaseFirestore.instance.collection("users");
userlist.get().then((dataSnapshot){
print("(2)Executing Get Data ");
FirebaseFirestore.instance.collection("users").get().then((QuerySnapshot snapshot){
if(snapshot.size == 0)
{
awarenessLevel = 1;
print("Snapshot Data error");
}else{
snapshot.docs.forEach((doc) async {
print(doc["awarenessLevel"]);
print(doc["email"]);
print(doc["Name"]);
print(doc["Address"]);
print(doc["NIC"]);
print(doc["mobile"]);
print(doc["Home phone"]);
Map<String,String> UserDetails = {
"awarenessLevel" : doc["awarenessLevel"],
"email" : doc["email"],
"Name" : doc["Name"],
"Address" : doc["Address"],
"NIC" : doc["NIC"],
"mobile" : doc["mobile"],
"Home phone" : doc["Home phone"],
};
print("Getting Final awareness level ... ");
awarenessLevel = UserDetails.containsKey(awarenessLevel) as int;
print("Final Awareness"+awarenessLevel.toString());
});
}
});
});
}
NotificationPlugin._() {
init();
}
......@@ -29,8 +76,11 @@ class NotificationPlugin {
_requestIOSPermission();
}
initializePlatformSpecifics();
getAwareness();
print("Awareness Level After init"+awarenessLevel.toString());
}
initializePlatformSpecifics() {
var initializationSettingsAndroid =
AndroidInitializationSettings('app_notf_icon');
......@@ -75,6 +125,7 @@ class NotificationPlugin {
}
Future<void> showNotification() async {
var androidChannelSpecifics = AndroidNotificationDetails(
'CHANNEL_ID',
'CHANNEL_NAME',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment