Find list of Local Notification the app has already set
UIApplication
has a property called scheduledLocalNotifications
which returns an optional array containing elements of type UILocalNotification
.
UIApplication.shared.scheduledLocalNotifications
NSUserNotification - How open the app when clicked
Just implement the NSUserNotificationCenterDelegate and define this method:
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
Example:
This is what I did in a "notifier" application.
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
NSRunAlertPanel([notification title], [notification informativeText], @"Ok", nil, nil);
}
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didDeliverNotification:(NSUserNotification *)notification
{
notifications=nil;
[tableView reloadData];
[center removeDeliveredNotification: notification];
}
When the notification is activated (click by the user) I just inform the user with a panel (I could use a hud window).In this case I immediately remove the delivered notification, but this is not what happens usually.The notification could stay there some time and be removed after 1/2 hours (it depends on the application that you are developing).
Detecting when a space changes in Spaces in Mac OS X
As Peter says, in 10.6 you can use the NSWorkSpace
NSWorkspaceActiveSpaceDidChangeNotification
to get a notification when the workspace changes.
You can then determine the current space using Quartz API, the kCGWindowWorkspace
dictionary key holds the workspace.
e.g:
int currentSpace;
// get an array of all the windows in the current Space
CFArrayRef windowsInSpace = CGWindowListCopyWindowInfo(kCGWindowListOptionAll | kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
// now loop over the array looking for a window with the kCGWindowWorkspace key
for (NSMutableDictionary *thisWindow in (NSArray *)windowsInSpace)
{
if ([thisWindow objectForKey:(id)kCGWindowWorkspace])
{
currentSpace = [thisWindow objectForKey(id)kCGWindowWorkspace] intValue];
break;
}
}
Alternatively you can get the Space using the private API, take a look at CGSPrivate.h which allows you to do this:
int currentSpace = 0;
CGSGetWorkspace(_CGSDefaultConnection(), ¤tSpace);
To change the screen resolution you'll want to look at Quartz services, for altering the volume this may be helpful.
How can I detect that the Shift key has been pressed?
From the Cocoa event handling guide:
The flagsChanged: method can be useful for detecting the pressing of modifier keys without any other key being pressed simultaneously. For example, if the user presses the Option key by itself, your responder object can detect this in its implementation of flagsChanged:.
More details can be found here.
The documentation for NSResponder also states the following:
flagsChanged:
Informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on).
-- (void)flagsChanged:(NSEvent *)theEvent
How to customise dialog message to prompt user for opening setting page
Before iOS 6 it was possible to set the purpose property on the CLLocationManager class but this has long been deprecated in favor of using the NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription strings in the Info.plist.
As far as I am aware there is no other way to replace this message. See original documentation
Apple Developer Documentation
Related Topics
How to Call a Func Within a Closure
Value of Type 'Authdataresult' Has No Member 'Uid'
Swift: Filter a Dictionary with Array as Value
How to Take a Substring to the First Index of a Character
Swift: Download Image from Internet and Cache Them Doesn't Work Properly. Need Suggestions
Swift Uikit Dynamics Add Collision Boundary. After Rotation Does Not Work Correctly
Firebase Datadescription Returns Empty Array
How to Implement Multiple Pangestures (Draggable Views)
How to Execute Different Implementation of a Method of a Generic Struct Based on the Generic Type
Color Ouput with Swift Command Line Tool
Swift: Implementing Protocol Initializer in a Class
Use Huge Numbers in Apple Swift
Realitykit - How to Add Motion to a Loaded Modelentity from Usdz File
How to Group an Array of Image Urls Together in Firebase Realtime Database? (Swift)
Interrupted Purchase Not Calling Delegate After Accepting T&C
How to Store the Progress of Progressview into Arraylist as One Element