I am trying to configure my app in order to use the "Local Push Connectivity" as depicted in the WWDC 2020 session.
I created my app and my extension, with the "Network Extension" Entitlement.
In the Info.plist of my extension, I've added the required configuration:
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.networkextension.app-push</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).PushProvider</string>
</dict>
And I have created the extension class as follow:
class PushProvider: NEAppPushProvider {
...
}
Now, in the AppDelegate
, I'm trying to configure the extension as follow:
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)")
})
The saveToPreferences
method always returns the following error:
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
I can't understand what is wrong with my configuration, since it seems that I follow all the necessary steps for the configuration.
Anyone has used this particular feature of iOS?