【发布时间】:2017-08-06 18:01:46
【问题描述】:
UINotificationAction 定义如下
let customAction = UNNotificationAction(identifier: "customCategory.Action", title: "Do something", options: [])
点击后,这将使用UNUserNotificationCenterDelegate 方法发出网络服务请求以获取数据,如下所示
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let actionIdentifier = response.actionIdentifier
switch actionIdentifier {
case customCategory.Action:
if authTokenNotExpired {
// Make service call
} else {
// Show login screen (In foreground)
}
}
completionHandler()
}
但应用程序已经登录,当授权令牌过期时,Web 服务请求失败。
根据要求,在这种失败情况下,应该显示登录屏幕。
是否可以将应用程序从后台模式移动到前台以显示登录屏幕?
【问题讨论】:
-
你不能让应用自己进入前台。虽然您可以更改根控制器,并在需要时显示登录屏幕!
-
显示登录界面,只有当用户点击右键再次启动应用程序时才会出现?
标签: ios swift push-notification ios10