简体   繁体   English

如何在 flutter 后台收到本地通知时调用 function

[英]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.

相关问题 如何在收到通知且应用程序处于后台时调用 android 中的另一个活动 - How to call another activity in android when notification received and app is in background 当应用程序在后台或被杀死时,如何在收到通知时启动我的应用程序或活动? - how can i launch my app or an activity on notification received when app is in background or killed? 在后台收到通知时,如何让我的android应用执行代码? - How can I get my android app to execute code when a notification is received when it's in background? 如何折叠 Flutter 中的通知? 使用本地推送通知插件和 CloudFunctions - How can I collapse notification in Flutter? using Local Push Notification plugin and CloudFunctions 如何收到Android中收到的通知的回电? - How do I get a call back for notification received in android? 当我单击在后台运行的通知时,它总是调用 MainActivity ,我如何调用我的 WebVIew - When I clicked notification run in background it's always call MainActivity , How I can call my WebVIew Flutter:Android:如何制作带有一些操作按钮的不可移动的本地通知工具栏,如屏幕截图所示 - Flutter: Android: How can i make unremovable local notification toolbar with some action button on it as shown in screenshot 应用在Android中一天后台运行后,如何发出本地通知 - How can I make an local notification after app go to background a day in Android 收到通知时如何启动后台作业 - how to start background job when a notification received 在颤振本地通知中调用 HTTP 请求 - Call a HTTP request in flutter local notification
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM