-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding notification feature in jadwal Sholat
- Loading branch information
Showing
26 changed files
with
404 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"enableCMake": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"CurrentProjectSetting": "No Configurations" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"ExpandedNodes": [ | ||
"", | ||
"\\lib", | ||
"\\lib\\screens" | ||
], | ||
"SelectedNode": "\\lib\\screens\\detail_doa_screen.dart", | ||
"PreviewInSolutionExplorer": false | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@raw/adzan" /> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Flutter | ||
import UIKit | ||
import XCTest | ||
|
||
class RunnerTests: XCTestCase { | ||
|
||
func testExample() { | ||
// If you add code to the Runner application, consider adding tests here. | ||
// See https://developer.apple.com/documentation/xctest for more information about using XCTest. | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; | ||
|
||
import 'package:timezone/timezone.dart' as tz; | ||
|
||
class NotificationService { | ||
final FlutterLocalNotificationsPlugin notificationsPlugin = | ||
FlutterLocalNotificationsPlugin(); | ||
|
||
final sound = 'adzan.mp3'; | ||
|
||
Future<void> initNotification() async { | ||
AndroidInitializationSettings initializationSettingsAndroid = | ||
const AndroidInitializationSettings('icon'); | ||
|
||
var initializationSettingsIOS = DarwinInitializationSettings( | ||
requestAlertPermission: true, | ||
requestBadgePermission: true, | ||
requestSoundPermission: true, | ||
onDidReceiveLocalNotification: | ||
(int id, String? title, String? body, String? payload) async {}); | ||
|
||
var initializationSettings = InitializationSettings( | ||
android: initializationSettingsAndroid, iOS: initializationSettingsIOS); | ||
await notificationsPlugin.initialize(initializationSettings, | ||
onDidReceiveNotificationResponse: | ||
(NotificationResponse notificationResponse) async {}); | ||
} | ||
|
||
notificationDetails() { | ||
return NotificationDetails( | ||
android: AndroidNotificationDetails( | ||
'your_channel_id', | ||
'channelName', | ||
playSound: true, | ||
sound: RawResourceAndroidNotificationSound('adzan'), | ||
importance: Importance.max, | ||
priority: Priority.high, | ||
), | ||
iOS: DarwinNotificationDetails()); | ||
} | ||
|
||
Future showNotification( | ||
{int id = 0, String? title, String? body, String? payLoad}) async { | ||
return notificationsPlugin.show( | ||
id, title, body, await notificationDetails()); | ||
} | ||
|
||
Future scheduleNotification( | ||
{int id = 0, | ||
String? title, | ||
String? body, | ||
String? payLoad, | ||
required DateTime scheduledNotificationDateTime}) async { | ||
return notificationsPlugin.zonedSchedule( | ||
id, | ||
title, | ||
body, | ||
tz.TZDateTime.from(scheduledNotificationDateTime, tz.local), | ||
await notificationDetails(), | ||
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, | ||
uiLocalNotificationDateInterpretation: | ||
UILocalNotificationDateInterpretation.absoluteTime); | ||
} | ||
} |
Oops, something went wrong.