推送通知功能在Xcode 11中没有选择器

我试图了解有关iOS上的推送通知的信息。为此,我正在阅读Raywenderlich的书。

另一方面,我已经意识到,在Xcode 11上,配置xcodeproj时已经进行了一些重新排列/更改,其中之一是用于启用Push通知的功能和选择器。

推送通知功能在Xcode 11中没有选择器

在这一点上,我不确定它是打开还是关闭。

这就是权利文件的内容。

<?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>

至少显示它已配置

在我的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)

}

应用启动时,请求了推送通知权限,但从未调用didRegisterForRemoteNotificationsWithdevicetoken

所以,我知道在以前版本的Xcode中有一个On / Off选择器,所以:

  • 它是开还是关?
  • didRegisterForRemoteNotificationsWithdevicetoken从未被称为关联的事实吗?

编辑

  • 在真实设备上。
  • 让Xcode处理所有签名。
lugogogo 回答:推送通知功能在Xcode 11中没有选择器

是的,只需添加即可,添加即表示您接受应用接收通知。

也在此处检查

https://developer.apple.com/documentation/xcode/adding_capabilities_to_your_app

本文链接:https://www.f2er.com/3096016.html

大家都在问