Session708-What's New in User Notifications

Notification OverView

Session开头总结了目前Notification的特性

  • Local Notification(本地通知)
  • Remote Notification (远程通知)
  • Notification Trigger (可以通过Push 定时 Calendar map等触发Notification)
  • Notification Presentation
  • Notification Actions (通知上添加动作)
  • Notification Remove (可以移除收到的通知)
  • Notification Service Extensive(在显示通知前提供修改的机会)
  • Notification Content Extensive (在通知上显示定制的视图)
    以上内容可以参考 WWDC2016-Introduction to User Notifications 及 Advanced User Notifications

Hidden Notification Content

当锁屏时若收到了推送时会直接显示在锁屏界面上,如果这些推送消息涉及到了个人隐私信息的话会对用户造成影响,因此iOS11中可以在Gloabal Setting或单独的App Setting中可以设置推送信息具体内容的显示时机(如只在解锁手机时等,总是,总不等),如果设置禁止显示具体内容则系统会用默认的语句取代推送消息中的内容去展示。同时iOS也提供新的api给开发者去使用自己的定制默认语句代替系统的默认语句.

Session708-What's New in User Notifications_第1张图片
屏幕快照 2017-07-30 下午5.36.56.png
Session708-What's New in User Notifications_第2张图片
屏幕快照 2017-07-30 下午5.36.31.png

在UNNotificationCategory初始化中指定placeHolder。
开发者也可以通过showPreviewsSetting来获取用户的关于hiddenNotificationConent的设置

Best Practise - Modify Push Content

本段讲解如何Modify Push Content的一些应用场景

Session708-What's New in User Notifications_第3张图片
屏幕快照 2017-07-30 下午5.51.08.png

首先在payload中设置mutable-content字段为1,这样iOS在收到这条推送时就调用Content Service
然后在Content Service 模板中进行对推送消息的处理

Session708-What's New in User Notifications_第4张图片
屏幕快照 2017-07-30 下午5.52.42.png

在处理前先保存回调方法和推送过来的方法,以便在后面完成修改后进行回调

Session708-What's New in User Notifications_第5张图片
屏幕快照 2017-07-30 下午5.54.35.png

但是在Content Service是有运行时间限制的,系统在终止Content Service前会调用上面的方法通知你

Customizing Rich Notification (Content Service)

用途:

  • App specific look and feel
  • Custom display of notification content
  • Interactive and dynamic UI
    可以修改的通知内容:
  • 自定义标题
  • 自定义UI
  • 移除重复的默认内容
    以下是使用Content Service时要在info.plist中增加的字段


    Session708-What's New in User Notifications_第6张图片
    屏幕快照 2017-07-30 下午6.05.47.png

User Input Customization

支持交互的控件

  • Media buttons
    实现相应地方法


    Session708-What's New in User Notifications_第7张图片
    屏幕快照 2017-07-30 下午6.19.43.png
  • Actions
    在Action 回调方法中处理相应的UI


    Session708-What's New in User Notifications_第8张图片
  • Custom input views
    实现相应的方法 返回自定义的inputView


    Session708-What's New in User Notifications_第9张图片
    屏幕快照 2017-07-30 下午6.22.05.png

你可能感兴趣的:(Session708-What's New in User Notifications)