0

I have implemented the notificationServiceExtension as mentioned by onesignal in it's documentation but now I am not being able to run background notification handler in one signal. I have implemented the following code in main activity:::

   package com.example.just_normal

import com.onesignal.OneSignal
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel

private val methodchannel = "background/notification";

class MainActivity: FlutterActivity() {
    
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        OneSignal.OSRemoteNotificationReceivedHandler { context, osNotificationReceivedEvent ->
             val CHANNEL : MethodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger , methodchannel)
            CHANNEL.invokeMethod("onBackgroundNotification" , osNotificationReceivedEvent);
            // osNotificationReceivedEvent.complete(null);
        }
   }

}

In the above code I am trying to call the flutter method immediately after the notification has been received in the background. How can I run flutter method immediately after notification is received in backgound. Please help....

  • For this reason I don't use OneSignal, you can see my answer here https://stackoverflow.com/a/71331313/2877427 – AnasSafi Mar 03 '22 at 02:18

0 Answers0