gpt4 book ai didi

ios - 通知启动自定义方法/类

转载 作者:行者123 更新时间:2023-11-29 11:03:18 25 4
gpt4 key购买 nike

只是想确保我走在正确的道路上。

我正在创建本地通知作为闹钟。当用户点击按钮时...我希望它做一些事情。

我在想我必须调用我的方法

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions.. .for 当应用程序关闭时

  • (void)applicationWillEnterForeground:(UIApplication *)application...当应用程序在后台时...当用户点击确定时

有没有更好的方法来完成我想要完成的事情...当用户在通知上点击确定时做一些事情?

提前致谢

最佳答案

根据本地通知和推送通知的文档,您应该在这两种情况下调用application:didFinishLaunchingWithOptions::

Handling Local and Remote Notifications

Let’s review the possible scenarios when the operating delivers a local notification or a remote notification for an application.

The notification is delivered when the application isn’t running in the foreground. In this case, the system presents the notification, displaying an alert, badging an icon, perhaps playing a sound. As a result of the presented notification, the user taps the action button of the alert or taps (or clicks) the application icon.

If the action button is tapped (on a device running iOS), the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method (if implemented); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications). If the application icon is tapped on a device running iOS, the application calls the same method, but furnishes no information about the notification .

关于ios - 通知启动自定义方法/类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14804403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com