Questions tagged [notificationcenter]

Notification Center is an interface designed by Apple that allows users to easily view notifications from all applications in one view. Notification Center is available in iOS 5 and up.

Notification Center is an interface designed by Apple that allows users to easily view notifications from all applications in one view. Notification Center is activated by dragging down from the devices status bar (top of screen), and removed similarly by dragging up from the bottom of the screen.

Options for Notification Center include:

  • Weather widget (powered by Yahoo)
  • Stocks widget (powered by Yahoo)
  • Sort by time
  • Sort manually (allows users to manually arrange the order in which notifications will appear from top to bottom)
  • Ability to enable/disable notifications for individual applications

Notification Center is available in iOS 5 and up.

242 questions
0
votes
1 answer

How to send local notification to user when they leave the app IOS

I am working on a timer application that should terminate if the user leaves the app. I want a notification to be sent to the user when they leave the application. This notification WARNS the user that the timer will terminate if they do not return…
Chris A.P
  • 11
  • 2
0
votes
1 answer

FCM-How to differentiate it is send from Firebase Console or HTTP when user click on the notification

I manage to set up everything and I can sent notification from method 1(Firebase Console) or 2(HTTP Send using Javascript and Ajax) Now after message sent, when user click on the notification, how to know it is from method 1(Firebase Console) or…
0
votes
1 answer

swift observer does not work

override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: .UIKeyboardWillShow, object: nil) …
0
votes
2 answers

How to send and receive UISlider value from one view controller to another

I'm trying to use NotificationCenter to send slider values (audio volume) to another view controller which contains the all the audio engine that I need. From the sender VC I tried this: @IBAction func vol1ChangedFromMixer(sender: UISlider) { …
Sktsalad
  • 23
  • 4
0
votes
1 answer

Simplify swift notification center events and observers

I started new swift project recently. I wanted to simplify usage of notifications and notification observers, so wrote some code for that. So I wanted to share this code and also ask about any possible issues? Event, class which post event to…
Vadims Krutovs
  • 197
  • 2
  • 3
0
votes
0 answers

Synchronizing state between tabs in UITabBarController

An app has a set of screens (tabs) configured with the UITabBarController. Each tab has own UINavigationController instance. Each UINavigationBar has a button with dropdown. Selecting a row in a dropdown should trigger a contentReload event in some…
0
votes
1 answer

Swift NotificationCenter passing userInfo to observing view controller

I'm trying to pass userInfo from an object to an observing view controller. For some reason it keeps crashing. Here's the code: Observer: NotificationCenter.default.addObserver( self, selector: #selector(self.alarmFired(_:)), …
rharding
  • 551
  • 1
  • 3
  • 14
0
votes
1 answer

Swift MVVM Pattern · Separation of Layers

(This question applies equally to MVC and other patterns but I'm currently working on an MVVM based app.) In the MVVM pattern; the View acts directly on the ViewModel which, in turn, acts directly on the Model which notifies the ViewModel to which…
Vince O'Sullivan
  • 2,611
  • 32
  • 45
0
votes
1 answer

iOS Widgets & Notification Center

Do Widgets in iOS 11 run in the foreground or background? Are Widgets updated/call the containing app when the Today View or Notification Center is simply interacted with on an iPhone? or must the Widget be physically touched/selected to update or…
0
votes
1 answer

Observers don't get called using NotificationCenter Swift 4.0

I have a two ViewControllers: ViewController and SecondViewController. I added an observer to this two ViewControllers. In ViewController I also defined an IBAction to post the notification. I handle the notification via a closure in both…
user1895268
  • 1,559
  • 3
  • 11
  • 23
0
votes
0 answers

NotificationCenter observe problems

Having some trouble with the swift3 -> swift4 conversion. This was my original code before the conversion: NotificationCenter.default.addObserver(self, selector: #selector(DataCollectionViewController.playerItemDidReachEnd), name:…
tchen2
  • 61
  • 4
0
votes
0 answers

UIDeviceBatteryLevelDidChange does not work in background?

ViewController.swift NotificationCenter.default.addObserver(self, selector: #selector(batteryLevelDidChange(_:)), name: .UIDeviceBatteryLevelDidChange, object: nil) @objc func batteryLevelDidChange(_ notification: Notification) { …
user1951072
  • 65
  • 1
  • 6
0
votes
1 answer

Notificationcenter function being called multiple times on one click?

I have an app which utilizes a NotificationCenter to call a function in viewControllerA when a button is pressed in viewControllerB. It works as intended, kind of. Here is the general setup: ViewControllerA override func viewDidLoad() { …
Runeaway3
  • 1,439
  • 1
  • 17
  • 43
0
votes
1 answer

iOS - NotificationCenter addObserver "UIMenuControllerWillHideMenu"

I have added notification observer for UIMenuControllerWillHideMenu but it does not call selector added/associated with notification center. UIMenuControllerWillHideMenu is notification center identifier for UIMenuController and should be called…
Krunal
  • 77,632
  • 48
  • 245
  • 261
0
votes
1 answer

Observing Notification in Today Widget which is posted from main app

I have declared notification name in a swift file which has target membership of both main app and today widget: let SpecialKey = Notification.Name("howLongNotif") Then in my main app view controller, I am posting notification when location is…
Kashif
  • 4,642
  • 7
  • 44
  • 97