1
0
Fork 0

Revert "For #373 - Integrate leanplum-fcm"

This reverts commit ed239ec250.

We're choosing to revert LeanPlum push messaging integration since we believe
that this has introduced a crash in Firebase push messaging. To verify
this assumption we're reverting this change, and when confirmed, we can
re-introduce Leamplum in a safer manner.

See #6250 and #6251 for related info.
master
Jonathan Almeida 2019-10-24 12:48:45 -04:00 committed by Jonathan Almeida
parent e26f4a9a6e
commit 59c0fb504e
5 changed files with 1 additions and 75 deletions

View File

@ -341,7 +341,6 @@ dependencies {
implementation Deps.sentry
implementation Deps.leanplum
implementation Deps.leanplumMessaging
implementation Deps.osslicenses_library
implementation Deps.mozilla_concept_engine

View File

@ -54,18 +54,6 @@
-keep class org.mozilla.fenix.**ViewModel { *; }
####################################################################################################
# Leanplum
####################################################################################################
-keepclassmembers class * {
@com.leanplum.annotations.* <fields>;
}
-keep class com.leanplum.** { *; }
-dontwarn com.leanplum.**
####################################################################################################
# Adjust
####################################################################################################
@ -106,4 +94,3 @@
# Keep motionlayout internal methods
# https://github.com/mozilla-mobile/fenix/issues/2094
-keep class androidx.constraintlayout.** { *; }

View File

@ -4,40 +4,6 @@
package org.mozilla.fenix.components
import com.google.firebase.messaging.RemoteMessage
import mozilla.components.lib.push.firebase.AbstractFirebasePushService
import org.json.JSONObject
import org.mozilla.fenix.ext.components
class FirebasePush : AbstractFirebasePushService() {
// Helper function to help determine if the incoming message is from Leanplum
private fun RemoteMessage.isLeanplumChannel(): Boolean =
data[LEANPLUM_KEY]
?.let { JSONObject(it) }
?.getString(LEANPLUM_NAME_KEY) == LEANPLUM_CHANNEL_NAME
/**
* Overrides onMessageReceived to handle incoming Leanplum messages.
*/
override fun onMessageReceived(remoteMessage: RemoteMessage?) {
if (remoteMessage?.isLeanplumChannel() == true) {
val message = remoteMessage.data?.get(LEANPLUM_MESSAGE_KEY) ?: return
sendLeanplumMessage(message)
return
}
return super.onMessageReceived(remoteMessage)
}
private fun sendLeanplumMessage(message: String) {
applicationContext.components.backgroundServices.notificationManager.showMessage(message)
}
companion object {
private const val LEANPLUM_KEY = "lp_channel"
private const val LEANPLUM_NAME_KEY = "name"
private const val LEANPLUM_CHANNEL_NAME = "leanplum"
private const val LEANPLUM_MESSAGE_KEY = "lp_message"
}
}
class FirebasePush : AbstractFirebasePushService()

View File

@ -19,7 +19,6 @@ import androidx.core.app.NotificationManagerCompat
import androidx.core.content.getSystemService
import mozilla.components.concept.sync.DeviceEvent
import mozilla.components.concept.sync.TabData
import mozilla.components.support.base.ids.notify
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.R
@ -30,8 +29,6 @@ class NotificationManager(private val context: Context) {
companion object {
const val RECEIVE_TABS_TAG = "ReceivedTabs"
const val RECEIVE_TABS_CHANNEL_ID = "ReceivedTabsChannel"
const val DEFAULT_CHANNEL_TAG = "Default"
const val DEFAULT_CHANEL_ID = "DefaultChannel"
}
init {
@ -47,13 +44,6 @@ class NotificationManager(private val context: Context) {
context.getString(R.string.fxa_received_tab_channel_name),
context.getString(R.string.fxa_received_tab_channel_description)
)
createNotificationChannel(
DEFAULT_CHANEL_ID,
NotificationManager.IMPORTANCE_DEFAULT,
context.getString(R.string.app_name),
""
)
}
}
@ -98,21 +88,6 @@ class NotificationManager(private val context: Context) {
}
}
fun showMessage(message: String) {
val builder = NotificationCompat.Builder(context, DEFAULT_CHANEL_ID)
.setSmallIcon(R.drawable.ic_status_logo)
.setContentTitle(context.getString(R.string.app_name))
.setContentText(message)
.setWhen(System.currentTimeMillis())
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setDefaults(Notification.DEFAULT_VIBRATE or Notification.DEFAULT_SOUND)
val notification = builder.build()
with(NotificationManagerCompat.from(context)) {
notify(context, DEFAULT_CHANNEL_TAG, notification)
}
}
@TargetApi(Build.VERSION_CODES.O)
private fun createNotificationChannel(
channelId: String,

View File

@ -164,7 +164,6 @@ object Deps {
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakcanary}"
const val leanplum = "com.leanplum:leanplum-core:${Versions.leanplum}"
const val leanplumMessaging = "com.leanplum:leanplum-fcm:${Versions.leanplum}"
const val androidx_annotation = "androidx.annotation:annotation:${Versions.androidx_annotation}"
const val androidx_fragment = "androidx.fragment:fragment-ktx:${Versions.androidx_fragment}"