简体   繁体   English

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

[英]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 中有一个开/关选择器,所以:

  • Is it on or off?是开还是关?
  • Is the fact that didRegisterForRemoteNotificationsWithDeviceToken never gets called related? didRegisterForRemoteNotificationsWithDeviceToken 从未被称为相关的事实吗?

EDIT编辑

  • On a real device.在真实设备上。
  • Letting Xcode to deal with all the signing.让 Xcode 处理所有的签名。

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.

相关问题 推送通知切换选项在 xcode 11 中不可用。 甚至没有能力 - Push notification toggle option not available in xcode 11 . Not even in the capability iOS 11中是否已弃用静默远程推送通知? - Are silent remote push notifications deprecated in iOS 11? 除非连接到 Xcode,否则推送通知无法完全正常工作 - Push Notifications not FULLY working unless tethered to Xcode 如何在 Xcode 12 中启用推送通知 - How to enable push notifications in Xcode 12 Firebase推送通知不起作用iOS11 Swift 4.1 - Firebase Push notifications not working ios11 swift 4.1 无法使用Xcode,Swift3获取图像iOS Rich Push通知 - Cant get image iOS Rich Push notifications with Xcode, Swift3 OneSignal和最新的xcode:应用程序不要求推送通知 - OneSignal and latest xcode: app does not ask for push notifications 在 Xcode11.4 beta 中测试静默推送通知 - Testing silent push notifications in Xcode11.4 beta Xcode6 Swift添加远程推送通知并从PHP发送 - Xcode6 Swift add Remote Push Notifications and send from PHP iOS 11应该通过App Delegate方法或仅由UNDelegate方法处理推送通知 - iOS 11 should push notifications be handled by App Delegate method or solely by UNDelegate methods
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM