You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 15通知功能如何开启“Configure in App(在应用内配置)”选项

实现方案

这个「在App内配置通知」的选项是iOS 15及以上系统提供的官方能力,你只需要完成以下两步配置即可启用:

  • 实现UNUserNotificationCenterDelegate的对应方法
    你需要在App的通知中心委托实现中,添加userNotificationCenter:openSettingsForNotification:方法,系统检测到你实现了这个方法后,就会自动在通知左滑的选项列表中新增对应的入口,按钮文字会自动生成为「Configure in [你的App名称]」,不需要额外配置文案。
    示例代码如下:
// Objective-C 实现
- (void)userNotificationCenter:(UNUserNotificationCenter *)center 
       openSettingsForNotification:(UNNotification *)notification {
    // 此处编写跳转到App内通知设置页的逻辑
    // 支持拿到notification的请求信息做差异化跳转,也可以直接跳转到通用通知设置页
    UINavigationController *nav = (UINavigationController *)self.window.rootViewController;
    AppNotificationSettingsViewController *settingsVC = [[AppNotificationSettingsViewController alloc] init];
    [nav pushViewController:settingsVC animated:YES];
}
// Swift 实现
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification) {
    // 此处编写跳转到App内通知设置页的逻辑
    guard let nav = window?.rootViewController as? UINavigationController else { return }
    let settingsVC = AppNotificationSettingsViewController()
    nav.pushViewController(settingsVC, animated: true)
}
  • 正确设置UNUserNotificationCenter的委托
    确保你在App启动完成后,就给UNUserNotificationCenter.current()设置了delegate,且委托对象的生命周期足够长(比如可以设置为AppDelegate或者全局持有的对象,避免被释放导致方法无法触发)。

注意:这个选项的展示完全由系统控制,只要你实现了上述方法,系统就会自动展示,不需要额外申请权限或者配置其他参数。你提到的UNNotificationAction是长按通知展示的自定义操作,和这个能力确实属于两套不同的系统API。

内容的提问来源于stack exchange,提问作者nyestuer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 04:39:03