- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试配置我的应用,以便使用 WWDC 2020 session 中描述的“本地推送连接”。
我使用“网络扩展”授权创建了我的应用和扩展。
在我的扩展的 Info.plist 中,我添加了所需的配置:
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.networkextension.app-push</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).PushProvider</string>
</dict>
我创建了如下扩展类:
class PushProvider: NEAppPushProvider {
...
}
现在,在 AppDelegate
中,我尝试按如下方式配置扩展:
let pushManager = NEAppPushManager()
pushManager.matchSSIDs = ["SSID Name"]
pushManager.localizedDescription = "PushProvider"
pushManager.providerBundleIdentifier = "---my-product.name----.PushProvider"
pushManager.delegate = self
pushManager.isEnabled = true
pushManager.providerConfiguration = [
"host": "192.168.1.94"
]
pushManager.saveToPreferences(completionHandler: { error in
print("error? \(error)")
print("is active: \(pushManager.isActive)")
})
saveToPreferences
方法总是返回以下错误:
2021-04-15 12:39:59.416074+0200 PushTest[2452:411559] [] : Failed to get the configuration index while saving configuration PushProvider: Error Domain=NEConfigurationErrorDomain Code=10 "permission denied" UserInfo={NSLocalizedDescription=permission denied}
2021-04-15 12:39:59.416437+0200 PushTest[2452:411556] [] <NEAppPushManager: 0x283807e10>: Failed to save the configuration: Error Domain=NEConfigurationErrorDomain Code=10 "permission denied" UserInfo={NSLocalizedDescription=permission denied}
error? Optional(Error Domain=NEAppPushErrorDomain Code=3 "(null)")
is active: false
我不明白我的配置有什么问题,因为我似乎遵循了配置的所有必要步骤。
有人用过 iOS 的这个特殊功能吗?
最佳答案
根据 Apple 的 Local Push Connectivity page ,
To use the Local Push Connectivity API, your app must have the Network Extensions Entitlement with the app-push-provider value. Request this entitlement from the Entitlement Request Page. After you receive the entitlement, apply it to both your app target and your provider extension target.
根据我的经验,最后一步意味着在您的 Apple Developer account 中手动创建配置文件对于应用程序和网络扩展,使用所提到的权利。然后下载配置文件并将它们导入 Xcode 以用于应用程序目标和本地推送网络扩展目标。 (因此,关闭配置文件的自动 Xcode 管理。)
关于ios - 无法为本地推送连接配置 NEAppPushManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67107228/
我正在尝试配置我的应用,以便使用 WWDC 2020 session 中描述的“本地推送连接”。 我使用“网络扩展”授权创建了我的应用和扩展。 在我的扩展的 Info.plist 中,我添加了所需的配
我是一名优秀的程序员,十分优秀!