【问题标题】:Unable to receive moengage push notifications无法接收 moengage 推送通知
【发布时间】:2021-09-01 16:25:59
【问题描述】:

我浏览了moengage flutter 的文档,但无法收到通知 我还在仪表板中添加了 fcm 键。下面在我的实现中 当我通过 fcm 发送通知时工作正常 基本上我们有 2 种颤振 apk prod 和调试模式,我正在调试我已经在 moengage 仪表板中添加了调试包名称。 当我创建活动并向 android 所有用户发送推送时,它不起作用。请在这里帮忙

Application.kt 类

import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.GeneratedPluginRegistrant


import com.moengage.core.LogLevel
import com.moengage.core.MoEngage
import com.moengage.core.MoEngage.Builder
import com.moengage.core.config.FcmConfig
import com.moengage.core.config.LogConfig
import com.moengage.core.config.MiPushConfig
import com.moengage.core.config.PushKitConfig
import com.moengage.core.config.NotificationConfig
import com.moengage.flutter.MoEInitializer
import com.moengage.pushbase.MoEPushHelper
import io.flutter.app.FlutterApplication

class Application : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        val moEngage = MoEngage.Builder(this, "hereIHaveAddedTheKey")
                .build()
        MoEngage.initialise(moEngage)
    }

    override fun registerWith(registry: PluginRegistry?) {
        if (registry == null) return
    }
}

Build.gradle 依赖

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.android.support:multidex:1.0.3'
    /// ---- moengage sdk start----
    implementation("com.moengage:moe-android-sdk:11.2.00")
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation("com.google.firebase:firebase-messaging:20.3.0")
    implementation("androidx.lifecycle:lifecycle-process:2.2.0")
    implementation("com.moengage:hms-pushkit:2.0.01")
    implementation("com.moengage:rich-notification:2.2.00")
    implementation("androidx.core:core:1.3.1")
    implementation("androidx.appcompat:appcompat:1.2.0")
    /// --- end ----
}

app-> build.gradle

buildscript {
    ext.kotlin_version = '1.5.21'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.5'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是颤振moengage初始化

 final MoEngageFlutter _moengagePlugin = MoEngageFlutter();

  void initialise() {
    _moengagePlugin.initialise();
  }

  void initState() {
    super.initState();
    initialise();
  }

主要文件

<service android:name="com.moengage.firebase.MoEFireBaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

【问题讨论】:

    标签: flutter dart moengage


    【解决方案1】:

    您可以添加显示推送通知所需的元数据,并使用提供的 API 将有效负载传递给 SDK。请参阅此处的文档 - https://docs.moengage.com/docs/push-configuration

    【讨论】:

    • configureNotificationMetaData(NotificationConfig(R.drawable.small_icon, R.drawable.large_icon, R.color.notiColor, null, true, isBuildingBackStackEnabled = false, isLargeIconDisplayEnabled = true) 这里实际上我有编译错误small_icon 和 large_icon 我该如何修复它们
    • 我已经在清单文件中添加了 Firebase 接收器,请参阅上面的更新问题
    • 我猜你指的是我们在存储库中的示例。如果您看到我们在应用程序的可绘制文件夹中有占位符小图标和大图标。您可以将名称替换为实际的图标名称。如果您不确定如何进行此操作,请随时通过 support@moengage.com 给我们写信,我们的团队将为您提供帮助。
    • 好的,试试这些东西,谢谢你,先生
    • 您添加了无法理解 MoEngage SDK 有效负载的 Mixpanel 接收器。您需要通过文档中提供的 API 将有效负载传递给 SDK,或者使用 MoEngage 的接收器。根据问题编辑更新了答案中的链接。
    猜你喜欢
    • 2012-12-24
    • 2018-04-22
    • 2017-12-08
    • 2017-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多