/// <summary> /// Receives a Message from GCM. The method exctracts a message from the Bundle data, /// and calls SendNotification. /// /// If the students have enabled receiveNotifications, but /// disabled receiveProjectNotifications and receiveJobNotifications /// The student can still receive more general messages sent as push notifications /// however these notifications will only be displayed once and won't be displayed in the /// notification list. /// </summary> public override async void OnMessageReceived(string from, Bundle data) { DbStudent dbStudent = new DbStudent(); var message = data.GetString("message"); Log.Debug("MyGcmListenerService", "From: " + from); Log.Debug("MyGcmListenerService", "Message: " + message); var type = data.GetString("type"); var uuid = data.GetString("uuid"); Student student = dbStudent.GetStudent(); if (student != null && student.receiveNotifications) { DbNotification dbNotification = new DbNotification(); if (type == "project") { if (student.receiveProjectNotifications) { SendNotification(message); Log.Debug("MyGcmListenerService", "type: " + type); Log.Debug("MyGcmListenerService", "uuid: " + uuid); // type = job or project Log.Debug("MyGcmListenerService", "After New NotificationController, but before use of method."); dbNotification.InsertNotification(type, uuid); } } else if (type == "job") { if (student.receiveJobNotifications) { SendNotification(message); Log.Debug("MyGcmListenerService", "type: " + type); Log.Debug("MyGcmListenerService", "uuid: " + uuid); // type = job or project Log.Debug("MyGcmListenerService", "After New NotificationController, but before use of method."); dbNotification.InsertNotification(type, uuid); } } else { SendNotification(message); } } }