【发布时间】:2014-02-22 22:26:31
【问题描述】:
我的 iOS 7 应用在 NSOperationQueue 块内调用的方法中生成本地通知。通知出现在通知中心,但它们没有在屏幕顶部显示横幅。应用在后台时正在生成通知。
我已经尝试了所有我能想到的方法,并且在 Google 上进行了大量搜索,但仍然无法显示横幅。
这是构建和安排通知的代码:
// In the most recent case, I have verified that
// alertText = Why not work? and alertAction = View
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = alertText;
localNotification.alertAction = alertAction;
localNotification.alertLaunchImage = launchImage;
UIApplication *application = [UIApplication sharedApplication];
application.applicationIconBadgeNumber++;
localNotification.applicationIconBadgeNumber = application.applicationIconBadgeNumber;
[self performSelectorOnMainThread:@selector(scheduleNotification:)
withObject:localNotification waitUntilDone:NO];
}
- (void)scheduleNotification: (id)notification
{
UILocalNotification *localNotification = (UILocalNotification *)notification;
// Schedule it with the app
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
我检查了我的应用的通知设置,它们是:
警报样式:横幅 徽章应用程序图标:开启 声音:关闭 在通知中心显示:开启 包括:5 最近的项目 在锁定屏幕上显示:开启
【问题讨论】:
标签: ios ios7 background notifications