There are some cases at VPNM app (PacketTunnelProvider, for iOS/macOS), in which I want to display an alert to the user from the Extension.
Till recently, I used the function displayMessage() which is now deprecated.
So now I'm using UNUserNotificationCenter, but there are some issues with that:
1. How can I display notifications from the extension, if the user chose not to authorize notifications? Sure, he can choose to do that, but then I don't have any valid way to display notifications from the extension?
2. Is there a way to make the notification persistant? Something like an alert, which will require the user to press an "ok" button.
3. What happens when the device enters sleep mode? The notification will wake the device? Or will it be shown only after the device exit sleep mode? Or maybe it won't be shown at all..?
1. How can I display notifications from the extension, if the user chose not to authorize notifications?
You can’t. The trick here is to make your notifications helpful, which encourages the user to leave them enabled.
2. Is there a way to make the notification persistant?
There’s nothing you can at your end. Most notifications do persist in Notification Center, but that’s largely under user control.
3. What happens when the device enters sleep mode?
If the device is truly asleep, your code is not running and hence can’t post a notification.
Are are you talking about screen lock, that is, the device is awake but the screen is locked / off?
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
ps DTS is closed 21 Dec through 1 Jan.