GOFA Lessons SDK enables seamless integration of interactive video fitness lessons into your Flutter application, with robust tracking of user progress and engagement using Firebase Firestore.
A "play" refers to a single instance of a user interacting with a specific lesson. It includes starting, pausing, resuming, and ending the lesson. Each play is uniquely identified by a playId and can have multiple sessions corresponding to different parts of the lesson.
A "plan play" is an interaction involving a lesson plan, which consists of a combination of lessons. It encompasses starting, pausing, resuming, resetting, and completing the entire plan. Each plan play is denoted by a unique planPlayId.
Data is organized into collections for Plans, Lessons, Users, UserLessons, Plays, PlanPlays, UserPlans, and DailyRecords.
Let's explore some common use cases and how they map to the technical structure:
When a user finishes a lesson:
Users > Plays collection.totalRepCount and totalSecondsSpent.lastPlayed and totalPlays fields are updated both in the Users > UserLessons subcollection and the Lessons collection.Users > Plays is marked as ended.void finishLesson(String gofaUserId, String playId) async {
await FirebaseFirestore.instance.collection('Users').doc(gofaUserId).collection('Plays').doc(playId).update({
'status': 'ended',
});
}When a user cancels a lesson play:
Users > Plays collection.void cancelLesson(String gofaUserId, String playId) async {
await FirebaseFirestore.instance.collection('Users').doc(gofaUserId).collection('Plays').doc(playId).update({
'status': 'cancelled',
});
}When a user completes a lesson plan:
planPlay in Users > PlanPlays is updated to "ended".totalRepCount and totalSecondsSpent are computed and recorded in the Firestore document.lastPlayed and totalPlays fields of the lesson plan in the Users > UserPlans subcollection, as well as the Plans collection, are updated accordingly.void finishPlan(String gofaUserId, String planPlayId) async {
await FirebaseFirestore.instance.collection('Users').doc(gofaUserId).collection('PlanPlays').doc(planPlayId).update({
'status': 'ended',
});
}gofaUserId (Documents)
Add the SDK
Use OnePub to add gofa_lessons to your project.
onepub pub add gofa_lessonsAdd Required Packages
flutter pub add get_itInitialize the SDK
Register and initialize LessonSdkManager with your client credentials and environment.
Localization
Add GofaLessonLocalizationsDelegate() to your MaterialApp's localizationsDelegates.
See the SDK Versions page for the latest changes and upgrade instructions.