gpt4 book ai didi

ios - 如何一次在本地通知中将日期数组设置为fireDate

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

实际上,在我的应用程序中,我在不同时间启动了两个以上的计时器。在一定的时间间隔后,我希望触发通知。当应用程序在前台但不在后台时,它工作正常。我该如何解决这个问题?

请帮忙。谢谢!

最佳答案

你需要做以下...

enter image description here

您需要开启后台模式。

在 AppDelegate 中,添加此代码以在后台运行应用程序

创建属性

@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTask;

然后执行以下...

- (void)applicationDidEnterBackground:(UIApplication *)application {

self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
DLOG(@"End of tolerate time. Application should be suspended now if we do not ask more 'tolerance'");

}];

if (self.backgroundTask == UIBackgroundTaskInvalid) {
DLOG(@"This application does not support background mode");
} else {
//if application supports background mode, we'll see this log.
DLOG(@"Application will continue to run in background");
}

}

希望对您有所帮助。

关于ios - 如何一次在本地通知中将日期数组设置为fireDate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42647210/

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