I would like to use the UserNotificationFramework on iOS 10 to send myself data only notifications -- i.e., with no user facing text or sound. Basically to use it as a persistent timer to be able to trigger the app, if running when it fires, to check for things like session timeout due to token expiry.
Kind of like an analog to a "content-available" faceless push notification in a local notification.
I have it all working except I cannot get a notification to fire without some sort of user facing data needing to be involved.
Here are the relevant pieces of the UNMutableNotificationContent of the UNNotificationRequest that is added to the UNUserNotificationCenter to trigger the notification.
// content.body = "Expiration"
// content.sound = UNNotificationSound(named: "silent-short.wav")
content.threadIdentifier = typeIdentifier
content.userInfo = ["1":"One"]
content.setValue("YES", forKey: "shouldAlwaysAlertWhileAppIsForeground")
As above the notification does not fire at all. If I uncomment either one of those lines -- does not matter which one -- it will fire. But I don't want a text notification banner displaying to the user (in or outside the app) so the first one does not help. I tried to use a silent sound, so that the system can think it is playing the sound but the user experiences nothing. But the system throws in a handy vibrate. Which in this case is not so handy. Is there a way to get the notification to not vibrate? Or any other way to get a local data only notification?