0

I have go through the documentation of moengage flutter but unable to receive the notifications i have added fcm keys in dashboard also. Below in my implementation When i am sending notification through fcm are working fine basically we have 2 modes of flutter apk prod and debug and i am working on debug i have added debug package name in moengage dashboard. when i create campaign and send a push to android all users its not working. Please help here

Application.kt class

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 dependency

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
}

This is flutter moengage initialization

 final MoEngageFlutter _moengagePlugin = MoEngageFlutter();

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

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

mainefestFile

<service android:name="com.moengage.firebase.MoEFireBaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>
Lalit Rawat
  • 1,022
  • 2
  • 17
  • 39

1 Answers1

0

You to add the required metadata for showing push notification and also pass the payload to the SDK using provided API. Refer to the documentation here - https://docs.moengage.com/docs/push-configuration

Umang
  • 966
  • 2
  • 7
  • 17
  • configureNotificationMetaData(NotificationConfig(R.drawable.small_icon, R.drawable.large_icon, R.color.notiColor, null, true, isBuildingBackStackEnabled = false, isLargeIconDisplayEnabled = true) here actually i am having compiling error for small_icon and large_icon how do i fix them – Lalit Rawat Sep 01 '21 at 18:12
  • i have already added the firebase receiver in manifest file please see the the updated question above – Lalit Rawat Sep 01 '21 at 18:14
  • I am guessing you are referring to the example we have in the repository. If you see we have placeholder small and large icons in the drawable folder of the application. You can replace the names with the actual icon names. In case you are not sure how to proceed on this feel free to write to us at support@moengage.com and our team will help you out. – Umang Sep 01 '21 at 18:16
  • okay trying these things and will let you know thank you sir – Lalit Rawat Sep 01 '21 at 18:17
  • You have added the Mixpanel receiver which will not understand MoEngage SDK's payload. You need to either pass the payload to the SDK via the provided API in the documentation or use MoEngage's receiver. Updated the links in the answer based on the question edit. – Umang Sep 01 '21 at 18:18
  • can you tell me 1 thing how do moengage know where it needs to send notification like in prod app or debug app – Lalit Rawat Sep 01 '21 at 18:40
  • Please drop an email to the above mentioned e-mail id and our team will help you out. – Umang Sep 02 '21 at 03:18