usernotifications

UNUserNotificationCenter Swift - Local Notification Not Firing in specific cases

假如想象 提交于 2019-12-12 10:02:52
问题 I'm facing issue while using Local Notifications in application. I'm scheduling local notification with custom content & custom action category. It's scheduling & firing in iOS 11, but not in iOS 10. As per documentation, it should be worked in iOS 10 as well. Please review my code, and let me why it's not working in such specific cases. Code is below. AppDelegate.swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey:

Repeating local notification not updating content

蹲街弑〆低调 提交于 2019-12-11 08:55:46
问题 I made an app that sends a local notification showing the user a random prime number every day at 9 AM. The issue is that the shown number is always the same. The code that creates the Notification Request only gets called once (which I kind of expected, being the Notification a repeating one), how then can I update its content? I can provide the code that generates the random prime number, but I've tested it and it works, so I don't think that's necessary (please let me know if otherwise).

User Notification: Custom Vibration pattern

戏子无情 提交于 2019-12-10 18:21:23
问题 Is it possible to create custom vibration pattern for the user notification alert? example, we can choose to have different audio for the user notification. Is it possible to have custom vibration pattern as well? I mean do this programmatically on iOS using swift. 回答1: For create custom vibrations in iOS. Use AudioServicesPlaySystemSoundWithVibration and AudioServicesStopSystemSound. Heart Beat Vibration Example NSMutableDictionary* pulsePatternsDict = [@{} mutableCopy]; NSMutableArray*

Swift3 Xcode 8: 'none' is unavailable: use [] to construct an empty option set ; What should I do?

爱⌒轻易说出口 提交于 2019-12-10 03:57:58
问题 I was using the UIUserNotificationType.none in Swift3 on ViewController.swift, and I got this error: 'none' is unavailable user[] to construct an empty option set ; Here is my code: func updateUI() { let currentSettings = UIApplication.shared.currentUserNotificationSettings if currentSettings?.types != nil { if currentSettings!.types == [UIUserNotificationType.badge, UIUserNotificationType.alert] { textField.isHidden = false button.isHidden = false datePicker.isHidden = false } else if

Usernotification framework badge does not increase

最后都变了- 提交于 2019-12-08 17:21:08
问题 I am using UserNotification framework in my app and sending local notifications (not push notifications), and I want to set the badge to the number of notifications received so what I did was to set the number of notifications received into a user default then I tried to assign the value to the badge to get me a badge number but the badge number would not increase. This is my code below To set value of received notification center.getDeliveredNotifications { notification in UserDefaults

How to use UNNotificationPresentationOptions

泪湿孤枕 提交于 2019-12-08 08:29:28
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 I have implemented the foreground notification by Adding the below code in my viewController extension UIViewController: UNUserNotificationCenterDelegate { public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping

UNUserNotificationCenter Swift - Local Notification Not Firing in specific cases

微笑、不失礼 提交于 2019-12-06 05:55:50
I'm facing issue while using Local Notifications in application. I'm scheduling local notification with custom content & custom action category. It's scheduling & firing in iOS 11, but not in iOS 10. As per documentation, it should be worked in iOS 10 as well. Please review my code, and let me why it's not working in such specific cases. Code is below. AppDelegate.swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { ....... if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate =

How to handle UNNotificationAction when app is closed?

限于喜欢 提交于 2019-12-05 11:35:38
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 notification... maybe i can't handle background task and i always have to launch app? Yes, it always

Swift3 Xcode 8: 'none' is unavailable: use [] to construct an empty option set ; What should I do?

社会主义新天地 提交于 2019-12-05 04:59:14
I was using the UIUserNotificationType.none in Swift3 on ViewController.swift, and I got this error: 'none' is unavailable user[] to construct an empty option set ; Here is my code: func updateUI() { let currentSettings = UIApplication.shared.currentUserNotificationSettings if currentSettings?.types != nil { if currentSettings!.types == [UIUserNotificationType.badge, UIUserNotificationType.alert] { textField.isHidden = false button.isHidden = false datePicker.isHidden = false } else if currentSettings!.types == UIUserNotificationType.badge { textField.isHidden = true } else if currentSettings!

Is there still a ~64 local notification limit for the new UserNotifications in iOS 10?

天涯浪子 提交于 2019-12-05 02:12:44
问题 In everything before iOS 9 there was a limit of 64 notifications that could be scheduled at any one time. Is this still true with the new notification system or can I schedule as many in advance as I'd like with the new UNUserNotifications? 回答1: Yes. I just updated an app of mine that schedules a lot of local notifications and the 64 limit is still in place. 来源: https://stackoverflow.com/questions/40685128/is-there-still-a-64-local-notification-limit-for-the-new-usernotifications-in-i