unusernotificationcenter

How can I remove previously delivered notifications when a new notification arrives with UNUserNotificationCenterDelegate in iOS 10?

若如初见. 提交于 2019-11-27 23:45:44
问题 This question is about the new UserNotifications framework in iOS 10. I have an app that schedules a local notification every half hour after the user did a certain action in the app, starting at 1 hour. To avoid cluttering a user's lock screen or notification center, I only want one notification to show up at a time, so there is only one notification with the most recent, relevant information. My plan to achieve this is to clear all delivered notifications any time a new notification is

Alternative to UserNotificationCenterDelegate's willPresent when app is in background

南楼画角 提交于 2019-11-27 09:37:20
I am trying to figure out whether I can accomplish my goal through Local Notifications, or whether I need to switch to Remote Notifications. I'm practicing iOS 10 / Swift 3 by building an alarm program that plays the latest episode of a RSS-updated radio show at a set time of day. When the app is in the foreground, this is easy to execute through UNUserNotificationCenterDelegate's willPresent function. I just use willPresent to fetch the latest episode, and play it through an AVAudio Player. Of course, if the app only works in the foreground, this functionality is very limited. I would want

Enable or Disable Iphone Push Notifications inside the app

南笙酒味 提交于 2019-11-27 07:16:51
I have a iphone app which is enable to receive push notifications. Currently i can disable push notifications for my app by going to the iphone settings/Notifications. But i want to add a switch or button inside my app to enable or disable push notifications. It can be done because i saw it in foursqure iphone app did it. They got a section in settings call notification settings and user can enable or disable different kind of notification for the app. I look all over the net to find a proper solution for this but still not found a way. Can any one please give any idea how to do that ? Thanks

UIApplication.registerForRemoteNotifications() must be called from main thread only

好久不见. 提交于 2019-11-27 03:27:00
Xcode 9 (iOS 11) showing me an error/warning while registering for Push (remote) notification. Here is error message And here is code, I've tried: let center = UNUserNotificationCenter.current() center.delegate = self center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in if error == nil{ UIApplication.shared.registerForRemoteNotifications() } } Error/Warning Line: UIApplication.shared.registerForRemoteNotifications() How to resolve this? Wasim K. Memon In swift4 You can solve this issue with DispatchQueue.main.async(execute: { UIApplication.shared

Add Local Notification in iOS 10 - Swift 3

北战南征 提交于 2019-11-26 22:32:12
So I been trying to add a notification to the new UNUserNotificationCenter, but I don't seem to get it. My view controller has an action: @IBAction func sendPressed(_ sender: AnyObject) { let content = UNMutableNotificationContent() content.title = "Hello" content.body = "What up?" content.sound = UNNotificationSound.default() // Deliver the notification in five seconds. let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false) let request = UNNotificationRequest.init(identifier: "FiveSecond", content: content, trigger: trigger) // Schedule the notification. let

Alternative to UserNotificationCenterDelegate's willPresent when app is in background

走远了吗. 提交于 2019-11-26 14:49:16
问题 I am trying to figure out whether I can accomplish my goal through Local Notifications, or whether I need to switch to Remote Notifications. I'm practicing iOS 10 / Swift 3 by building an alarm program that plays the latest episode of a RSS-updated radio show at a set time of day. When the app is in the foreground, this is easy to execute through UNUserNotificationCenterDelegate's willPresent function. I just use willPresent to fetch the latest episode, and play it through an AVAudio Player.

Enable or Disable Iphone Push Notifications inside the app

僤鯓⒐⒋嵵緔 提交于 2019-11-26 13:09:17
问题 I have a iphone app which is enable to receive push notifications. Currently i can disable push notifications for my app by going to the iphone settings/Notifications. But i want to add a switch or button inside my app to enable or disable push notifications. It can be done because i saw it in foursqure iphone app did it. They got a section in settings call notification settings and user can enable or disable different kind of notification for the app. I look all over the net to find a proper

UIApplication.registerForRemoteNotifications() must be called from main thread only

吃可爱长大的小学妹 提交于 2019-11-26 10:33:31
问题 Xcode 9 (iOS 11) showing me an error/warning while registering for Push (remote) notification. Here is error message And here is code, I\'ve tried: let center = UNUserNotificationCenter.current() center.delegate = self center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in if error == nil{ UIApplication.shared.registerForRemoteNotifications() } } Error/Warning Line: UIApplication.shared.registerForRemoteNotifications() How to resolve this? 回答1: In swift4 You can

Getting local notifications to show while app is in foreground Swift 3

允我心安 提交于 2019-11-26 05:58:07
问题 Apparently this is now possible with ios10 : optional func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) This answer basically says the tools needed to do it: Displaying a stock iOS notification banner when your app is open and in the foreground? I\'m just not really understanding how to put it all together. I dont know how important this is, but I\'m

Registering for Push Notifications in Xcode 8/Swift 3.0?

强颜欢笑 提交于 2019-11-26 01:42:13
问题 I\'m trying to get my app working in Xcode 8.0 , and am running into an error. I know this code worked fine in previous versions of swift, but I\'m assuming the code for this is changed in the new version. Here\'s the code I\'m trying to run: let settings = UIUserNotificationSettings(forTypes: [.Sound, .Alert, .Badge], categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(settings) UIApplication.shared().registerForRemoteNotifications() The error that I\'m