Fix notifications not showing

Add channel when building notification for daily reminder
Extend WakefulBroadcastReceiver instead of BroadcastReceiver
Remove android:process=":remote" in the manifest

Fixes #1105
This commit is contained in:
Angelo Viado 2019-03-09 11:40:55 +09:00 committed by Phillip Thelen
parent bd07638350
commit 59b39772d3
2 changed files with 5 additions and 7 deletions

View file

@ -188,11 +188,9 @@
<activity android:name=".ui.activities.VerifyUsernameActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<receiver android:process=":remote" android:name=".receivers.NotificationPublisher" />
<receiver android:name=".receivers.NotificationPublisher" />
<receiver
android:process=":remote"
android:name=".receivers.TaskReceiver"/>
<receiver android:name=".receivers.TaskReceiver"/>
<receiver android:name=".receivers.LocalNotificationActionReceiver"
android:exported="false">

View file

@ -3,6 +3,7 @@ package com.habitrpg.android.habitica.receivers
import android.app.Notification
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
@ -10,7 +11,6 @@ import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.legacy.content.WakefulBroadcastReceiver
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.data.TaskRepository
@ -31,7 +31,7 @@ import javax.inject.Inject
@Suppress("DEPRECATION")
//https://gist.github.com/BrandonSmith/6679223
class NotificationPublisher : WakefulBroadcastReceiver() {
class NotificationPublisher : BroadcastReceiver() {
@Inject
lateinit var taskRepository: TaskRepository
@ -96,7 +96,7 @@ class NotificationPublisher : WakefulBroadcastReceiver() {
private fun buildNotification(wasInactive: Boolean, registrationDate: Date? = null): Notification? {
val thisContext = context ?: return null
val notification: Notification
val builder = NotificationCompat.Builder(thisContext)
val builder = NotificationCompat.Builder(thisContext, "default")
builder.setContentTitle(thisContext.getString(R.string.reminder_title))
var notificationText = getRandomDailyTip()
if (registrationDate != null) {