Skip to content
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

Umich Notification Foundation #565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECEIVE_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<queries>
<intent>
Expand Down Expand Up @@ -62,5 +66,8 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />

<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver" android:exported="false" />

</application>
</manifest>
22 changes: 19 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import 'package:wger/screens/workout_plans_screen.dart';
import 'package:wger/theme/theme.dart';
import 'package:wger/widgets/core/about.dart';
import 'package:wger/widgets/core/settings.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:permission_handler/permission_handler.dart';

import 'providers/auth.dart';

Expand All @@ -61,8 +63,22 @@ void main() async {

// Locator to initialize exerciseDB
await ServiceLocator().configure();

// Application
runApp(MyApp());

// Request notification permission
await _requestNotificationPermission();
}

Future<void> _requestNotificationPermission() async {
// Request notification permission
var status = await Permission.notification.request();
if (status.isGranted) {
print('Notification permission granted');
} else {
print('Notification permission denied');
}
}

class MyApp extends StatelessWidget {
Expand Down Expand Up @@ -91,11 +107,11 @@ class MyApp extends StatelessWidget {
),
ChangeNotifierProxyProvider<AuthProvider, NutritionPlansProvider>(
create: (context) => NutritionPlansProvider(
WgerBaseProvider(Provider.of<AuthProvider>(context, listen: false)),
context, WgerBaseProvider(Provider.of<AuthProvider>(context, listen: false)),
[],
),
update: (context, auth, previous) =>
previous ?? NutritionPlansProvider(WgerBaseProvider(auth), []),
previous ?? NutritionPlansProvider(context, WgerBaseProvider(auth), []),
),
ChangeNotifierProxyProvider<AuthProvider, MeasurementProvider>(
create: (context) => MeasurementProvider(
Expand Down Expand Up @@ -155,7 +171,7 @@ class MyApp extends StatelessWidget {
HomeTabsScreen.routeName: (ctx) => HomeTabsScreen(),
MeasurementCategoriesScreen.routeName: (ctx) => MeasurementCategoriesScreen(),
MeasurementEntriesScreen.routeName: (ctx) => MeasurementEntriesScreen(),
NutritionalPlansScreen.routeName: (ctx) => NutritionalPlansScreen(),
NutritionScreen.routeName: (ctx) => NutritionScreen(),
NutritionalDiaryScreen.routeName: (ctx) => NutritionalDiaryScreen(),
NutritionalPlanScreen.routeName: (ctx) => NutritionalPlanScreen(),
WeightScreen.routeName: (ctx) => WeightScreen(),
Expand Down
Loading
Loading