Skip to content

Commit

Permalink
Add notification troubleshooter
Browse files Browse the repository at this point in the history
🔥 remove unnecessary print
  • Loading branch information
iqfareez committed Aug 1, 2021
1 parent ee3e590 commit 4181734
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 39 deletions.
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Future<void> _configureLocalTimeZone() async {
tz.setLocalLocation(tz.getLocation(timeZoneName));
}

// ignore_for_file: avoid_print
void readAllGetStorage() {
// print (almost) all GetStorage item to the console
print("-----All GET STORAGE-----");
Expand Down
4 changes: 0 additions & 4 deletions lib/notificationUtil/isolate_handler_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void schedulePrayNotification(List<dynamic> times) async {

DebugToast.show('SCHEDULING $howMuchToSchedule notifications');

print('howMuchToSchedule is $howMuchToSchedule');
// for debug dialog
GetStorage().write(kNumberOfNotifsScheduled, howMuchToSchedule);

Expand Down Expand Up @@ -105,8 +104,6 @@ void schedulePrayNotification(List<dynamic> times) async {
scheduledTime: tz.TZDateTime.from(
DateTime.fromMillisecondsSinceEpoch(isyakTimeEpoch), tz.local));
}

print('Notification scheduled #${i + 1}');
}

scheduleAlertNotification(
Expand All @@ -120,7 +117,6 @@ void schedulePrayNotification(List<dynamic> times) async {
1, 0, 5), //2021-01-01 00:05:00.000+0800
);

print('DONE SCHEDULING NOTIFS');
DebugToast.show('FINISH SCHEDULE NOTIFS');

//This timestamp is later used to determine wether notification should be updated or not
Expand Down
75 changes: 48 additions & 27 deletions lib/views/Settings part/NotificationSettingPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'troubleshoot_notif.dart';
import '../../CONSTANTS.dart';
import '../../utils/cupertinoSwitchListTile.dart';
import '../../utils/custom_navigator_pop.dart';
Expand All @@ -28,23 +29,43 @@ class _NotificationPageSettingState extends State<NotificationPageSetting> {
const Padding(padding: EdgeInsets.all(8.0), child: Text('Basic')),
Card(
child: ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
title: const Text('App notification System Setting'),
isThreeLine: true,
subtitle: const Text(
'Customize sound, toggle channel of prayer notification etc.'),
trailing: const Icon(Icons.launch_rounded),
trailing: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Icon(Icons.launch_rounded),
],
),
onTap: () async {
await AppSettings.openNotificationSettings();
},
),
),
const Padding(
padding: EdgeInsets.all(8.0), child: Text('Troubleshooting')),
Card(
child: ListTile(
title:
const Text('Fix notification didn\'t show on some device.'),
subtitle: const Text('Example: Xiaomi / Redmi, Realme etc.'),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const TroubleshootNotif(),
)),
),
),
const Padding(
padding: EdgeInsets.all(8.0),
child: Text('Advanced troubleshooting')),
Card(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: CupertinoSwitchListTile(
activeColor: CupertinoColors.activeBlue,
title: const Text('Limit notification scheduling'),
subtitle: const Text(
'Enable if you experiencing an extreme slowdown in app. Notification will schedule weekly basis. Default is OFF (monthly).'),
Expand All @@ -61,30 +82,30 @@ class _NotificationPageSettingState extends State<NotificationPageSetting> {
title: const Text('Force rescheduling notification...'),
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: const Text(
'By default, notification will not rescheduled if the last scheduler ran is less than two days.\n\nTap proceed to start an immediate notification scheduling. The app will be restarted.'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
GetStorage().write(kForceUpdateNotif, true);
print(GetStorage().read(kForceUpdateNotif));
Get.forceAppUpdate();
CustomNavigatorPop.popTo(context, 3);
},
child: const Text('Proceed'),
)
],
);
});
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: const Text(
'By default, notification will not rescheduled if the last scheduler ran is less than two days.\n\nTap proceed to start an immediate notification scheduling. The app will be restarted.'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
GetStorage().write(kForceUpdateNotif, true);
Get.forceAppUpdate();
CustomNavigatorPop.popTo(context, 3);
},
child: const Text('Proceed'),
)
],
);
},
);
},
),
),
Expand Down
75 changes: 75 additions & 0 deletions lib/views/Settings part/troubleshoot_notif.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:app_settings/app_settings.dart';
import 'package:flutter/material.dart';
import '../../utils/launchUrl.dart';

class TroubleshootNotif extends StatelessWidget {
const TroubleshootNotif({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text.rich(
TextSpan(
style: TextStyle(height: 1.3),
children: [
TextSpan(text: 'Some apps installed from the '),
TextSpan(
text: 'Google Play Store ',
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(text: 'will disable '),
TextSpan(
text: 'Autostart ',
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(
text:
'by default. Due to this behaviour, prayer notification (sometimes) will not appear on your phone. '),
],
),
),
const Text('\n'),
const Text.rich(
TextSpan(
style: TextStyle(height: 1.3),
children: [
TextSpan(text: 'The solution is to enable '),
TextSpan(
text: 'Autostart ',
style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(
text:
'for this app. Tap the button below to open App Setting, then find the Autostart option there to enable it.'),
],
),
),
Card(
child: ListTile(
title: const Text('Open App Setting'),
onTap: () => AppSettings.openAppSettings(),
trailing: const Icon(Icons.launch_rounded),
),
),
const Text(
'\nRelated Article:',
style: TextStyle(fontWeight: FontWeight.bold),
),
TextButton(
onPressed: () {
LaunchUrl.normalLaunchUrl(
url:
'https://telegra.ph/Notification-didnt-show-on-some-devices-07-31');
},
child:
const Text('Notification didn\'t show on some devices'))
],
),
),
),
);
}
}
1 change: 0 additions & 1 deletion lib/views/ZoneChooser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ class LocationChooser {

static Widget onErrorWidget(BuildContext context,
{@required String errorMessage, Function onRetryPressed}) {
print(errorMessage);
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
3 changes: 1 addition & 2 deletions lib/views/appBody.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class _AppBodyState extends State<AppBody> {
// Releases an ad resource when it fails to load
ad.dispose();

print(
'Ad load failed (code=${error.code} message=${error.message})');
throw error;
},
),
request: const AdRequest());
Expand Down
4 changes: 0 additions & 4 deletions lib/views/feedbackPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class _FeedbackPageState extends State<FeedbackPage> {
shrinkWrap: true,
itemCount: _deviceInfo.length + 1,
itemBuilder: (context, index) {
print(_deviceInfo.length);
if (index < _deviceInfo.length) {
var key = _deviceInfo.keys.elementAt(index);
return ListTile(
Expand Down Expand Up @@ -180,7 +179,6 @@ class _FeedbackPageState extends State<FeedbackPage> {
if (_formKey.currentState.validate()) {
FocusScope.of(context).unfocus();
setState(() => _isSendLoading = true);
print('Sending report...');
try {
await _reportsCollection.add({
'Date creation': FieldValue.serverTimestamp(),
Expand Down Expand Up @@ -214,8 +212,6 @@ class _FeedbackPageState extends State<FeedbackPage> {
backgroundColor: Colors.red,
));
setState(() => _isSendLoading = false);
} catch (e) {
print('Err: $e');
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: App waktu solat seluruh Malaysia

publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 1.26.137-pre.5+64
version: 1.26.138-pre.6+65

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down
1 change: 1 addition & 0 deletions scratch.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// import 'package:geolocator/geolocator.dart';
//ignore_for_file: avoid_print

import 'package:intl/intl.dart';

Expand Down

0 comments on commit 4181734

Please sign in to comment.