[英]How can I call a function on local notification received in background in flutter
I want to build one functionality in my flutter app.我想在我的 flutter 应用程序中构建一项功能。 I am using the awesome_notification package to show scheduled notifications.
我正在使用 awesome_notification package 来显示预定的通知。
Is there any way that I can trigger an API call when a notification is received in the background?有什么方法可以在后台收到通知时触发 API 呼叫? (when the app was killed or terminated).
(当应用程序被杀死或终止时)。 I want to do it on the flutter side but You can also suggest how to do it in native android and IOS if it is possible.
我想在 flutter 端进行,但如果可能的话,您也可以建议如何在本机 android 和 IOS 中进行。 Native integration would also be accepted.
本机集成也将被接受。
Please share a demo or example.请分享演示或示例。
Thanks!谢谢!
iOS Note: In iOS, you can determine whether an application is launched as a result of the user tapping the action button or whether the notification was delivered to the already-running application by examining the application state. In the delegate's implementation of the application:didReceiveRemoteNotification: or application:didReceiveLocalNotification: method, get the value of the applicationState property and evaluate it. iOS 注意:在 iOS 中,您可以通过检查应用程序 state 来确定应用程序是否因用户点击操作按钮而启动,或者通知是否已传递到已运行的应用程序。在委托的应用程序实现中: didReceiveRemoteNotification: 或 application:didReceiveLocalNotification: 方法,获取 applicationState 属性的值并对其进行评估。 If the value is UIApplicationStateInactive, the user tapped the action button;
如果值为 UIApplicationStateInactive,则用户点击了操作按钮; if the value is UIApplicationStateActive, the application was frontmost when it received the notification.
如果值为 UIApplicationStateActive,则应用程序在收到通知时处于最前面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.