Update subscription and review nagging

pull/1832/head
Alex Baker 3 years ago
parent 8952286dff
commit 49774a5ec5

@ -63,14 +63,15 @@ class Firebase @Inject constructor(
}) })
} }
val installCooldown: Boolean private val installCooldown: Boolean
get() = preferences.installDate + days("install_cooldown", 14L) > now() get() = preferences.installDate + days("install_cooldown", 14L) > now()
val reviewCooldown: Boolean val reviewCooldown: Boolean
get() = preferences.lastReviewRequest + days("review_cooldown", 30L) > now() get() = installCooldown || preferences.lastReviewRequest + days("review_cooldown", 30L) > now()
val subscribeCooldown: Boolean val subscribeCooldown: Boolean
get() = preferences.lastSubscribeRequest + days("subscribe_cooldown", 30L) > now() get() = installCooldown
|| preferences.lastSubscribeRequest + days("subscribe_cooldown", 30L) > now()
private fun days(key: String, default: Long): Long = private fun days(key: String, default: Long): Long =
TimeUnit.DAYS.toMillis(remoteConfig?.getLong(key) ?: default) TimeUnit.DAYS.toMillis(remoteConfig?.getLong(key) ?: default)

@ -9,9 +9,9 @@ import com.google.android.play.core.ktx.requestReview
import com.google.android.play.core.review.ReviewManagerFactory import com.google.android.play.core.review.ReviewManagerFactory
import com.todoroo.andlib.utility.DateUtilities.now import com.todoroo.andlib.utility.DateUtilities.now
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import org.tasks.R
import org.tasks.analytics.Firebase import org.tasks.analytics.Firebase
import org.tasks.preferences.Preferences import org.tasks.preferences.Preferences
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class PlayServices @Inject constructor( class PlayServices @Inject constructor(
@ -24,11 +24,6 @@ class PlayServices @Inject constructor(
suspend fun requestReview(activity: Activity) { suspend fun requestReview(activity: Activity) {
if (firebase.reviewCooldown) { if (firebase.reviewCooldown) {
Timber.d("review cooldown")
return
}
if (firebase.installCooldown) {
Timber.d("install cooldown")
return return
} }
try { try {
@ -36,9 +31,10 @@ class PlayServices @Inject constructor(
val request = requestReview() val request = requestReview()
launchReview(activity, request) launchReview(activity, request)
preferences.lastReviewRequest = now() preferences.lastReviewRequest = now()
firebase.logEvent(R.string.event_request_review)
} }
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e) firebase.reportException(e)
} }
} }
} }

@ -434,6 +434,7 @@
<string name="event_banner_beast">banner_beast</string> <string name="event_banner_beast">banner_beast</string>
<string name="event_banner_sub">banner_subscribe</string> <string name="event_banner_sub">banner_subscribe</string>
<string name="event_add_task">add_task</string> <string name="event_add_task">add_task</string>
<string name="event_request_review">request_review</string>
<string name="param_type">type</string> <string name="param_type">type</string>
<string name="p_map_theme">map_theme</string> <string name="p_map_theme">map_theme</string>
<string name="p_picker_mode_date">picker_mode_date</string> <string name="p_picker_mode_date">picker_mode_date</string>

Loading…
Cancel
Save