swift 从未调用本地推送通知NEAppPushProvider

iezvtpos  于 2023-05-16  发布在  Swift
关注(0)|答案(1)|浏览(128)


I配置了我的应用程序使用本地推送通知,我仍然在尝试我请求授权,我得到了苹果的批准,我为应用程序simplePush和SimplePushProvider创建了证书包括扩展网络两个证书都包括在一个组ID

let pushManager = NEAppPushManager()
pushManager.matchSSIDs = ["Tenda_6B8340","ouamassi", "Tenda_6B8340_5G", "192.168.1.7"]
  pushManager.localizedDescription = "PushProvider"
  pushManager.providerBundleIdentifier = "" // Here I put my id application of the 
 SimplePushProvider I created
 pushManager.delegate = self
 pushManager.isEnabled = true
 pushManager.providerConfiguration = [
  "host": "192.168.1.7”.    // This is the address ip of my Mac where the server is launched  
  ]
    pushManager.saveToPreferences(completionHandler: { error in
     print("error? \(error)")
   print("is active: \(pushManager.isActive)")
  })

我的SimplePushProvider是这样声明的:

class SimplePushProvider: NEAppPushProvider {
 private let channel = BaseChannel(port: Port.notification, heartbeatTimeout: 
.seconds(30), logger: Logger(prependString: "Notification Channel", subsystem: 
  .networking))
  private var cancellables = Set<AnyCancellable>()
  private let logger = Logger(prependString: "SimplePushProvider", subsystem: .general)

....

public override init() {
    super.init()
    public override func start() {
      logger.log("Started")

   ….

问题是SimplePushProvider从未被调用,并且pushManager始终处于非活动状态,我确信我的真实的设备连接到pushManager.matchSSID上包含的ssid我尝试了几个ssid,但仍然存在同样的问题
保存NEAppPushManager时没有错误
我真的坚持与这个问题几天任何帮助将不胜感激

hyrbngr7

hyrbngr71#

我也在尝试实现本地推送,遇到了和你一样的问题。
我能够通过以下方式解决这些问题:https://developer.apple.com/forums/thread/705382
得到了一些日志,让我通过使用“Console.app”(只需在Mac上运行“Console”)来了解问题。

相关问题