You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
Kotlin
40 lines
1.3 KiB
Kotlin
4 years ago
|
package org.mozilla.fenix.components
|
||
|
|
||
|
import android.content.Context
|
||
|
import mozilla.components.feature.push.AutoPushFeature
|
||
|
import mozilla.components.feature.push.PushConfig
|
||
|
import mozilla.components.support.base.log.logger.Logger
|
||
|
import org.mozilla.fenix.R
|
||
|
|
||
|
/**
|
||
|
* Component group for push services. These components use services that strongly depend on
|
||
|
* push messaging (e.g. WebPush, SendTab).
|
||
|
*/
|
||
|
class Push(context: Context) {
|
||
|
val feature by lazy {
|
||
|
pushConfig?.let { config ->
|
||
|
AutoPushFeature(
|
||
|
context = context,
|
||
|
service = pushService,
|
||
|
config = config
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private val pushConfig: PushConfig? by lazy {
|
||
|
val logger = Logger("PushConfig")
|
||
|
val projectIdKey = context.getString(R.string.pref_key_push_project_id)
|
||
|
val resId = context.resources.getIdentifier(projectIdKey, "string", context.packageName)
|
||
|
if (resId == 0) {
|
||
|
logger.warn("No firebase configuration found; cannot support push service.")
|
||
|
return@lazy null
|
||
|
}
|
||
|
|
||
|
logger.debug("Creating push configuration for autopush.")
|
||
|
val projectId = context.resources.getString(resId)
|
||
|
PushConfig(projectId)
|
||
|
}
|
||
|
|
||
|
private val pushService by lazy { FirebasePushService() }
|
||
|
}
|