What's New in Notifications(WWDC2015-Session 720)

Silent Notifications

WX20171013-001455@2x

  • Silent (don’t show UI to the user)
  • Romote notifications
  • Enabled by default(without ask the user for permission)
  • The mechanism behind background app refresh(user can go in settings ing and disable them)

User Notifications

  • Notify the user
  • Require user permission

Remote Notifications

  • Silent notification can inside a user notifications

Local Notifications

  • Scheduled by your own app(By time or location)
  • no server , no internet

Text Input Action (iOS 9)

1
2
3
4
5
6
7
8
9
10
11
12
13
//Registering

let replyAction = UIMutableUserNotificationAction()
replyAction.title = "Reply"
replyAction.identifier = "comment-reply"
replyAction.activationMode = .Background
replyAction.requiresAuthentication = false
replyAction.behavior = .TextInput

let category = UIMutableUserNotificationCategory() category.identifier = "reply"
category.actions = [ replyAction ]
let settings = UIUserNotificationSettings(forTypes: [ .Sound , .Alert ], categories: [ category ])
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//Receiving

func application(application: UIApplication, handleActionWithIdentifier identifier: String?,
forLocalNotification notification: UILocalNotification,
withResponseInfo responseInfo: [ NSObject : AnyObject ], completionHandler completionHandler: () -> Void) {
//Handling the response
if identifier == "comment-reply",
let response = responseInfo[UIUserNotificationActionResponseTypedTextKey],
responseText = response as? String {
viewController.appendText(responseText)
}
}
completionHandler()
}