gpt4 book ai didi

ios - 应用程序未运行或终止时的通知

转载 作者:行者123 更新时间:2023-11-28 21:30:04 25 4
gpt4 key购买 nike

我正在开发一个应用程序,当任何其他用户在应用程序中发布数据时我正在使用本地通知。当我的应用程序正在运行时它工作正常并且还显示通知。但是当我终止我的应用程序和任何其他用户发布数据时,我无法收到通知。有没有办法在我的应用程序终止时调用通知功能??

UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];
notification.alertBody = [NSString stringWithFormat:@"one person vote your post"];
[notificationArray addObject:@"one person vote your post"];
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

最佳答案

如果您从服务器获取其他帖子(使用网络服务),您应该实现推送通知而不是本地通知。

本地通知:您需要在您的应用正在使用时指定触发时间。

在您的情况下,当其他用户发帖时您的应用未运行。所以你不会得到触发事件。

关于ios - 应用程序未运行或终止时的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36475704/

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