Skip to content

Commit

Permalink
Add minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
gdelataillade committed Nov 21, 2023
1 parent 51fb555 commit 6174974
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ class AlarmPlugin: FlutterPlugin, MethodCallHandler {
}
"setNotificationOnKillService" -> {
val title = call.argument<String>("title")
val description = call.argument<String>("description")
val body = call.argument<String>("body")

val serviceIntent = Intent(context, NotificationOnKillService::class.java)
serviceIntent.putExtra("title", title)
serviceIntent.putExtra("description", description)
serviceIntent.putExtra("body", body)

context.startService(serviceIntent)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import io.flutter.Log

class NotificationOnKillService: Service() {
private lateinit var title: String
private lateinit var description: String
private lateinit var body: String
private val NOTIFICATION_ID = 88888
private val CHANNEL_ID = "com.gdelataillade.alarm.alarm_channel"

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
title = intent?.getStringExtra("title") ?: "Your alarms could not ring"
description = intent?.getStringExtra("description") ?: "You killed the app. Please reopen so your alarms can be rescheduled."
body = intent?.getStringExtra("body") ?: "You killed the app. Please reopen so your alarms can be rescheduled."

return START_STICKY
}
Expand All @@ -36,7 +36,7 @@ class NotificationOnKillService: Service() {
val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.ic_notification_overlay)
.setContentTitle(title)
.setContentText(description)
.setContentText(body)
.setAutoCancel(false)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setContentIntent(pendingIntent)
Expand All @@ -46,7 +46,7 @@ class NotificationOnKillService: Service() {
val descriptionText = "If an alarm was set and the app is killed, a notification will show to warn the user the alarm could not ring as long as the app is killed"
val importance = NotificationManager.IMPORTANCE_MAX
val channel = NotificationChannel(CHANNEL_ID, name, importance).apply {
description = descriptionText
body = descriptionText
}

// Register the channel with the system
Expand Down
9 changes: 0 additions & 9 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
android:label="alarm_example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service android:name="com.gdelataillade.alarm.services.NotificationOnKillService" />
<activity
android:name=".MainActivity"
Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExampleAlarmHomeScreen extends StatefulWidget {
class _ExampleAlarmHomeScreenState extends State<ExampleAlarmHomeScreen> {
late List<AlarmSettings> alarms;

static StreamSubscription? subscription;
static StreamSubscription<AlarmSettings>? subscription;

@override
void initState() {
Expand Down
9 changes: 0 additions & 9 deletions help/INSTALL-ANDROID.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ Inside the <application> tag of your AndroidManifest.xml, add the following decl
```xml
<application>
[...]
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service android:name="com.gdelataillade.alarm.services.NotificationOnKillService" />
[...]
</application>
Expand Down
4 changes: 2 additions & 2 deletions ios/Classes/SwiftAlarmPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public class SwiftAlarmPlugin: NSObject, FlutterPlugin {
}
}

let currentTime = self.audioPlayers[id]!.deviceCurrentTime
let time = currentTime + delayInSeconds
let currentTime = self.audioPlayers[id]!.deviceCurrentTime
let time = currentTime + delayInSeconds

let dateTime = Date().addingTimeInterval(delayInSeconds)
self.triggerTimes[id] = dateTime
Expand Down
2 changes: 1 addition & 1 deletion lib/src/android_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AndroidAlarm {
'setNotificationOnKillService',
{
'title': AlarmStorage.getNotificationOnAppKillTitle(),
'description': AlarmStorage.getNotificationOnAppKillBody(),
'body': AlarmStorage.getNotificationOnAppKillBody(),
},
);
} catch (e) {
Expand Down

0 comments on commit 6174974

Please sign in to comment.