-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No notification banner for all surveys not triggered initially with ImmediateTrigger() #316
Comments
Hi @Z-Setiadi, I have also experienced this issue with the Could you provide me with an example of a protocol you used to produce this behavior? |
Here is an example of the protocol: class LocalStudyProtocolManager implements StudyProtocolManager {
@override
Future<void> initialize() async {}
@override
Future<SmartphoneStudyProtocol> getStudyProtocol(String studyId) async {
SmartphoneStudyProtocol protocol = SmartphoneStudyProtocol(
name: 'blank',
ownerId: 'blank',
);
protocol.studyDescription = StudyDescription(
title: 'blank',
description:
"???",
purpose:
"???",
responsible: StudyResponsible(
id: 'blank',
title: 'blank',
address: 'blank',
affiliation: 'blank',
email: 'blank',
name: 'blank',
));
// Define the data end point , i.e., where to store data.
// This example app only stores data locally in a SQLite DB
protocol.dataEndPoint = SQLiteDataEndPoint();
// Define which devices are used for data collection.
Smartphone phone = Smartphone();
protocol.addPrimaryDevice(phone);
SamplingPackageRegistry().register(SurveySamplingPackage());
// task triggered by ImmediateTrigger()
// this should produce a notification banner
protocol.addTaskControl(
ImmediateTrigger(),
RPAppTask(
type: SurveyUserTask.SURVEY_TYPE,
title: surveys.selfReport.title,
description: surveys.selfReport.description,
minutesToComplete: surveys.selfReport.minutesToComplete,
notification: true,
rpTask: surveys.selfReport.survey,
),
phone);
// task triggered by RecurrentScheduledTrigger()
// this currently does not produce a notification banner
protocol.addTaskControl(
RecurrentScheduledTrigger(
type: RecurrentType.daily,
time: const TimeOfDay(hour: 8)),
RPAppTask(
type: SurveyUserTask.SURVEY_TYPE,
title: surveys.morning.title,
description: surveys.morning.description,
minutesToComplete: surveys.morning.minutesToComplete,
notification: true,
rpTask: surveys.morning.survey,
expire: const Duration(hours: 1),
),
phone);
// task triggered by RandomRecurrentTrigger()
// this currently does not produce a notification banner
protocol.addTaskControl(
RandomRecurrentTrigger(
startTime: const TimeOfDay(hour: 9),
endTime: const TimeOfDay(hour: 11),
minNumberOfTriggers: 1,
maxNumberOfTriggers: 1,
),
RPAppTask(
type: SurveyUserTask.SURVEY_TYPE,
title: surveys.dailyReport.title,
description: surveys.dailyReport.description,
minutesToComplete: surveys.dailyReport.minutesToComplete,
notification: true,
rpTask: surveys.dailyReport.survey,
expire: const Duration(hours: 1),
),
phone);
} And here is an example of a surveys file to use for this protocol: final surveys = _Surveys();
class _Surveys {
final Survey _morning = _MorningSurvey();
Survey get morning => _morning;
final Survey _dailyReport = _DailyReport();
Survey get dailyReport => _dailyReport;
final Survey _selfReport = _SelfReport();
Survey get selfReport => _selfReport;
}
/// An interface for an survey from the RP package.
abstract class Survey {
/// The title of this survey.
String get title;
/// A short description (one line) of this survey
String get description;
/// How many minutes will it take to do this survey?
int get minutesToComplete;
/// The survey to fill out.
RPTask get survey;
}
class _MorningSurvey implements Survey {
@override
String get title => "Morning Survey";
@override
String get description => "A short morning check-in.";
@override
int get minutesToComplete => 5;
final RPChoiceAnswerFormat _yesNo = RPChoiceAnswerFormat(
answerStyle: RPChoiceAnswerStyle.SingleChoice,
choices: [
RPChoice(text: "Yes", value: 1),
RPChoice(text: "No", value: 2),
]);
RPNavigableOrderedTask get survey => RPNavigableOrderedTask(
identifier: "morning",
steps: [
RPQuestionStep(
identifier: "test",
title: "Did you sleep well?",
answerFormat: _yesNo,
),
],
)
}
class _DailyReport implements Survey {
@override
String get title => "Daily Report";
@override
String get description => "A short daily check-in.";
@override
int get minutesToComplete => 5;
final RPChoiceAnswerFormat _yesNo = RPChoiceAnswerFormat(
answerStyle: RPChoiceAnswerStyle.SingleChoice,
choices: [
RPChoice(text: "Yes", value: 1),
RPChoice(text: "No", value: 2),
]);
RPNavigableOrderedTask get survey => RPNavigableOrderedTask(
identifier: "daily",
steps: [
RPQuestionStep(
identifier: "test",
title: "Did you sleep well?",
answerFormat: _yesNo,
),
],
)
}
class _SelfReport implements Survey {
@override
String get title => "Self Report";
@override
String get description => "A short self check-in.";
@override
int get minutesToComplete => 5;
final RPChoiceAnswerFormat _yesNo = RPChoiceAnswerFormat(
answerStyle: RPChoiceAnswerStyle.SingleChoice,
choices: [
RPChoice(text: "Yes", value: 1),
RPChoice(text: "No", value: 2),
]);
RPNavigableOrderedTask get survey => RPNavigableOrderedTask(
identifier: "morning",
steps: [
RPQuestionStep(
identifier: "test",
title: "Did you sleep well?",
answerFormat: _yesNo,
),
],
)
} |
Device Hardware / Emulator and OS
Describe the bug
I have multiple survey tasks in the protocol, and most of them utilize either the RecurrentScheduledTrigger() or the RandomRecurrentTrigger(). While the surveys are triggered, there are no notification banners for them. The only trigger that gives me a notification banner is the ImmediateTrigger(). I have all notifications allowed and each of the RPAppTasks has the notification parameter set to true.
To Reproduce
Expected behavior
I expected all three tasks to produce a notification banner.
Actual behavior
Only the task triggered by ImmediateTrigger() gives me a notification banner. The rest of the tasks are triggered but do not notify me.
The text was updated successfully, but these errors were encountered: