uilocalnotification

How to check that user is back from Settings

不打扰是莪最后的温柔 提交于 2020-08-08 06:21:40
问题 I am sending local notifications to my users, and I want to show the relevant title on the notification settings button. If local notifications are off, this title should be "Notifications: off", and if local notifications are on, this title should be something like "Preferences". Right now I'm checking this in viewDidLoad and viewDidAppear, and it works. if UIApplication.sharedApplication().currentUserNotificationSettings()?.types.rawValue == 0 { //the first title } else { //the second title

Using @available with stored properties

♀尐吖头ヾ 提交于 2020-06-25 07:25:10
问题 I have an app that uses local notifications and supports iOS 10. I am trying to add iOS 9 support which requires me to use the old location notification API. I am trying to use @available and #available on my iOS 10 code and I can't figure out how to get my center variable to only be for devices running iOS 10. When I set my target from iOS 10 to 9 I get the error message for this variable: "UNUserNotificationCenter is only available on iOS 10.0 or newer." It suggests I add "@available(iOS 10

Swift Local push notification action view

亡梦爱人 提交于 2020-06-25 06:30:40
问题 I'm trying to create a notification with two possible action buttons like "Quick reply" and "Cancel", but I can't find any code examples for this. Please could someone explain how to do this in Swift 3. 回答1: It's difficult to give a precise example of what you are looking for. Here's a quick UNUserNotificationCenter implementation with an action. import UserNotifications Define a category ID constant private let categoryID = "Category" Setup and register UNUserNotificationCenter // MARK: -

Swift Local push notification action view

匆匆过客 提交于 2020-06-25 06:30:26
问题 I'm trying to create a notification with two possible action buttons like "Quick reply" and "Cancel", but I can't find any code examples for this. Please could someone explain how to do this in Swift 3. 回答1: It's difficult to give a precise example of what you are looking for. Here's a quick UNUserNotificationCenter implementation with an action. import UserNotifications Define a category ID constant private let categoryID = "Category" Setup and register UNUserNotificationCenter // MARK: -

Schedule Local Notifications at Specific times in the day

偶尔善良 提交于 2020-06-11 09:44:20
问题 I want to setup a daily notification system for my app. It should notify the user twice a day, once at 8:00 AM (Hey there, your set of morning doses is ready. Wanna check it out?) and once at 7:00 PM (Ssup! Your evening Dose is waiting inside). I know that by doing this i'll run out of notifications in a month since there's a 64 notifications cap (for local notifications) but by then, the app will be live and i'll be done setting up remote notifications update. I've looked at this question:

nextTriggerDate() doesn't return the 'expected' value, is there another way to obtain the next fire date of a repeating Local Notification?

半腔热情 提交于 2020-05-24 03:42:28
问题 In my application I allow users to schedule repeating Local Notifications. The issue that I have though (any many others based on looking around) is that nextTriggerDate() always bases its return value on the current time rather than the time at which the notification was scheduled. I've seen suggestions to store a "date" value in the userInfo of the notification but seeing as how the notifications repeat, it doesn't seem like it would be able to keep this date value accurate each time the

nextTriggerDate() doesn't return the 'expected' value, is there another way to obtain the next fire date of a repeating Local Notification?

限于喜欢 提交于 2020-05-24 03:42:19
问题 In my application I allow users to schedule repeating Local Notifications. The issue that I have though (any many others based on looking around) is that nextTriggerDate() always bases its return value on the current time rather than the time at which the notification was scheduled. I've seen suggestions to store a "date" value in the userInfo of the notification but seeing as how the notifications repeat, it doesn't seem like it would be able to keep this date value accurate each time the

nextTriggerDate() doesn't return the 'expected' value, is there another way to obtain the next fire date of a repeating Local Notification?

风流意气都作罢 提交于 2020-05-24 03:42:06
问题 In my application I allow users to schedule repeating Local Notifications. The issue that I have though (any many others based on looking around) is that nextTriggerDate() always bases its return value on the current time rather than the time at which the notification was scheduled. I've seen suggestions to store a "date" value in the userInfo of the notification but seeing as how the notifications repeat, it doesn't seem like it would be able to keep this date value accurate each time the