title: flutter: pop a notification by receiving SMS when the app is closed
body: <p>I want to pop a notification (and upon clicking open the app) when some specfic event happens on the phone (in my case receiving a SMS with a predetermined format or from a specific phone number). Currently I use <a href="https://pub.dev/packages/sms" rel="noreferrer">flutter SMS package</a> and build an instance of SmsReceiver class in the main() as below and try to print the sms body to console:</p>
  
  <pre><code>void main() {
    SmsReceiver receiver = new SmsReceiver();
    receiver.onSmsReceived.listen((SmsMessage msg) =&gt; print(msg.body));
    runApp(MyApp());
  }
  </code></pre>
  
  <p>I test the code on a real device (Samsung Galaxy 8+). When app is running or in the background I get the sms body with no problem. However, as I close the app and receive a sms, following error? is printed in console:</p>
  
  <p><strong>W/FlutterJNI(23977): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: plugins.babariviere.com/recvSMS. Response ID: 0</strong></p>
  
  <p>Can you help me with this? Is it possible to listen for such events and trigger a notification even when the app is closed? </p>
  
  <p>p.s. I looked into <a href="https://pub.dev/packages/flutter_local_notifications" rel="noreferrer">flutter local notifications</a>. However, it looks like that this package only Schedules notifications to appear. In my case I want notifications to be event driven.</p>