usernotifications

How to call a function when the app is inactive (e.g. playing music in background)?

时光毁灭记忆、已成空白 提交于 2020-04-07 08:25:29
问题 I am making a music-streaming alarm clock. Music streams for the duration selected by the user, including in the background, and at the end of the duration a custom alarm sound is played in addition to a local notification. In short (1) set timer (2) local notification fires off (3) streamed music stops (4) alarm plays I am able to do (1) and (2) ok, but am unable to figure out how to trigger (3) or (4) when the app is in the background. Here is the code for (1) and (2) let center =

Background fetch execution time with iOS 10 UserNotifications without user interaction

烈酒焚心 提交于 2020-01-15 05:55:07
问题 In the Push Notification API before iOS 10, I could easily run a background job triggered by a Push Notification being received. Just received -- the user didn't have to interact with it at all. Now it seems in order for my same background jobs to be carried out with this new framework the user must interact with the notification somehow. Is there a way with this new framework to just run a background job when a certain push is just received by the client device, but not interacted with by

Is the iOS Local Notification Limit Per Day?

社会主义新天地 提交于 2020-01-01 03:15:12
问题 I'm working on an app where I need to send a good amount of notifications to the user daily. Around 5-40 depending on the user. I'm using local notifications to send it, but I know there is a 64 notification limit. Does this mean 64 notifications per day, or in total? 回答1: It means simultaneously scheduled for future delivery. You can send as many as you want per day, provided they don't overlap. If you add more than 64 requests (under UserNotifications ) or scheduled (under UIApplication /

How to create dateComponents from Date stored in CoreData

╄→尐↘猪︶ㄣ 提交于 2019-12-24 21:52:18
问题 I am trying to create dateComponents from Date stored in CoreData from UIDatePicker. However, I am not able to make it. I am first converting Date which is stored in editnotes?.sSelectedDate into dateComponents and then using the dateComponents for triggering my notifications. Here is what I am doing: var date = Date() if let editnote = editnotes { date = editnote.sSelectedDate } else { print("nil") } let calendar = NSCalendar.current let unitFlags = Set<Calendar.Component>([.day, .month,

Difference bwteen UNTimeIntervalNotificationTrigger and UNCalendarNotificationTrigger?

匆匆过客 提交于 2019-12-24 09:04:51
问题 My app is very notification dependent and I have recently noticed some notification issues which never used to be there before iOS 11.2. 1) Calling removeDeliveredNotifications on a notification by a UNCalendarNotificationTrigger does not remove it anymore, but it does remove notifications triggered by a UNTimeIntervalNotificationTrigger. (The fact that removeDeliveredNotifications doesn't work for UNCalendarNotificationTrigger seems very weird) 2) Pressing an action on a notification

How to use UNNotificationPresentationOptions

我们两清 提交于 2019-12-23 01:29:26
问题 In iOS 10 , there is an option for presenting the notification when the app is in foreground using UNNotificationPresentationOptions , but i couldn't find any sample on how to use this, please suggest some idea about how to implement this feature 回答1: I have implemented the foreground notification by Adding the below code in my viewController extension UIViewController: UNUserNotificationCenterDelegate { public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent

How to handle UNNotificationAction when app is closed?

放肆的年华 提交于 2019-12-22 06:53:45
问题 How to handle new iOS10 Notification Action when app is closed (not in background) ? when app is minimalized everything works fine with: UNUserNotificationCenter.current().delegate = x and handling it in class x: UNUserNotificationCenterDelegate { func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Swift.Void) { } } but nothing is called when app is closed and user tap action in