gpt4 book ai didi

iphone - 无法在 iPhone 应用程序中运行后台操作

转载 作者:行者123 更新时间:2023-12-03 20:27:52 25 4
gpt4 key购买 nike

我已经仔细阅读了有关多任务处理的苹果开发用户指南,但我仍然无法理解如何在后台运行简单的操作。我做了以下简单的实验,但什么也没发生:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
sleep(3);
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"title" message:@"test" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil , nil];
[alert1 show];
}

所以我知道默认情况下会在后台添加对音频/位置/VoIP 操作的支持,但如何添加对如此简单操作的支持?

非常感谢您的帮助。

最佳答案

我希望这个答案。对您的问题非常有用

当您关闭应用程序时,您可以在后台看到 AlertView 中的消息..

- (void)viewDidLoad

{


UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate =[NSDate dateWithTimeIntervalSinceNow:15];
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Staff meeting in 30 minutes";
//localNotif.alertBody = [NSString stringWithFormat:@"%@'s Birthday",strName];

localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
// localNotif.applicationIconBadgeNumber = 1;
localNotif.repeatInterval = NSYearCalendarUnit;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];


}

关于iphone - 无法在 iPhone 应用程序中运行后台操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11641996/

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