[英]Push notifications capability no selector in Xcode 11
I am try to learn about push notifications on iOS.我正在尝试了解 iOS 上的推送通知。 For that I am reading the Raywenderlich book.
为此,我正在阅读 Raywenderlich 的书。
On the other hand I have realised that, on Xcode 11, some rearrangements/changes have been done when configuring xcodeproj and one of them is the Capabilities and the selector for enabling Push notifications.另一方面,我已经意识到,在 Xcode 11 上,在配置 xcodeproj 时进行了一些重新排列/更改,其中之一是用于启用推送通知的功能和选择器。
At this point i am not sure if it is on or off.在这一点上,我不确定它是打开还是关闭。
That's the content of entitlements file.这就是权利文件的内容。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
Which at least shows it is configured至少表明它已配置
In my AppDelegate I have the following code:在我的 AppDelegate 我有以下代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { granted, _ in
guard granted else { return }
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
}
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.reduce("") { $0 + String(format: "%02x", $1) }
print(token)
}
When the app starts, push notifications permissions are requested but didRegisterForRemoteNotificationsWithDeviceToken
is never called.当应用程序启动时,请求推送通知权限,但从不调用
didRegisterForRemoteNotificationsWithDeviceToken
。
So, I know in previous versions of Xcode there is a On/Off selector so:所以,我知道在以前版本的 Xcode 中有一个开/关选择器,所以:
EDIT编辑
Yes, Just add it only, by adding it means that you accept that your app receive notifications.是的,只需添加它,添加它意味着您接受您的应用接收通知。
check here also也检查这里
https://developer.apple.com/documentation/xcode/adding_capabilities_to_your_app https://developer.apple.com/documentation/xcode/adding_capabilities_to_your_app
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.