gpt4 book ai didi

ios - 应用程序在后台时显示通知

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

当应用程序在后台运行时,我需要显示某些本地通知。如果没有 NSNotificationCenter 的帮助,我该怎么做?

最佳答案

安德烈·切尔努卡(Andrey Chernukha)的第一条评论是正确的。下面是实现简单本地通知的代码:

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.repeatInterval = 0;
NSDate *now = [NSDate date];
NSDate *dateToFire = [now dateByAddingTimeInterval:10];

localNotification.fireDate = dateToFire;
localNotification.alertBody = @"Test local notification";
localNotification.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

关于ios - 应用程序在后台时显示通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34686520/

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