title: Flutter method channel & Facebook AppEventLogger
body: <p>I am trying to call a function from flutter on onTap event and pass some arguments into native android. Please note that I am more of a PHP/JavaScript developer, I am Kotlin virgin.</p>
  
  <p>So far I have managed to do this using:</p>
  
  <pre><code>static const platform = const MethodChannel('foo.bar/example');
  
  void _onTap() {
     var arguments = {'name': widget.recipe.name, 'id': widget.recipe.id.toString()};
     platform.invokeMethod('setPageView', arguments);
  }
  </code></pre>
  
  <p>Then in the MainActivity.kt</p>
  
  <pre><code>class MainActivity : FlutterActivity() {
  private val channel: String = "foo.bar/example"
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      GeneratedPluginRegistrant.registerWith(this)
  
      val logger = AppEventsLogger.newLogger(this)
  
  
      MethodChannel(flutterView, channel).setMethodCallHandler(MethodChannel.MethodCallHandler(fun(methodCall: MethodCall, result: MethodChannel.Result) {
          if (methodCall.method.equals("setPageView")) {
              val params = Bundle()
  
              params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, "recipe")
              params.putString(AppEventsConstants.EVENT_PARAM_CONTENT, methodCall.argument("recipe"))
              params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, methodCall.argument("id"))
  
              logger.logEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT, 0.0, params)
  
              logger.logEvent("pageView", 0.0, params)
  
              System.out.println("Called setPageView.")
  
          }
      }))
    }
  }
  </code></pre>
  
  <p>The problem is that when I log inside the MethodCallHandler the event is not sent to facebook for some reason. But if I log something right below the </p>
  
  <pre><code>val logger = AppEventsLogger.newLogger(this)
  </code></pre>
  
  <p>The event is successfully sent to facebook.</p>
  
  <p>The code inside the MethodCallHandler executes, so that´s not the problem.</p>
  
  <p>Any idea what I did wrong?</p>
  
  <p>Thank You</p>