NetBeans - Programmatically Remove NotificationDisplayer Notifications - netbeans

The NetBeans API provides the org.openide.awt.NotificationDisplayer class to create and show clickable notifications in the main status line. For example,
NotificationDisplayer.notify(title, icon, detailsText, detailsAction);
The user can dismiss a notification by clicking on the X; however, I would like to programmatically clear the notifications. How can I accomplish this?

The solution I end up with was to maintain a reference to the Notification object returned by the NotificationDisplayer.notify() method. The object provides a clear() method to force removal from the status line.

Related

How to know if FCM's `onLaunch` callback is gonna be called or not

So my project has the different navigation logic based on how user launch my app: by tap the icon laucher or via FCM's notification's tap. The case is I don't know if the FCM's onLaunch callback is gonna be called or not to decide which logic to use. Is there any good approach to this problem?
You can check how your activitiy is started like this (You can use invoke method of flutter to get this result in flutter)
if("android.intent.action.MAIN".equals(getIntent().getAction())){
// By taping the icon launcher
}else{
//By other source
}

Function across multiple view controllers

I am trying to make a function so that I request a 'manager override' where it presents a screen for a manager to enter their password and press an approve button. How should I do this? Will it have to be in multiple functions? Is there a way that I can call one function and it present the information back? Would a completion work for what I need? I have no ideas where to start for this.
My set up is as follows:
A view controller asks for manager approval, then a screen slides up with text boxes and an approve button. I want the approve button to trigger authenticating and dismissing the screen
Assuming you don't want a Framework target (that sounds like overkill for what you want) simply mark the function as "public" and move it outside of any class. I just tried in a sample project and it works.
It looks important - remember to keep it in a file already in the project. (My sample project didn't work with menu option File|Add|New|File.)
Now, if you really want portability, check out how to create a Framework project.

Property additionalActions of NSUserNotification seems not working?

To understand NSUserNotification better, I wrote a little test app playing with this class.
So far so good, except that no matter how hard I tried to feed the additionalActions property with array of NSUserNotificationAction objects, it never showed any difference but only one action button and a close one.
My expectation for this property is that the notification would show a pull-down menu containing the additional buttons I offer as it does in the Mac App Store update notifications.
Am I missing something? Or are you having the same problem, since it is a bug awaiting Apple to tackle?
Can you please try to click and hold down the action button in your notification? Does it show a drop-down menu of additionalActions?
Update
As it turns out, you can show the little chevron next to the action button by setting a true value for the private _alwaysShowAlternateActionMenu key on the notification. In Swift 3, it would look like this:
notification.setValue(true, forKey: "_alwaysShowAlternateActionMenu")
However, as I mentioned this is a private API and I strongly advise against using it if you want to distribute your App through the Mac App Store.
It is probably a bug. Setting up additionalActions will create the list, but not the little arrow icon. Holding down on actionButton will show the menu with the number of actions you set.
Besides setting additionalActions will cause several other problems. I will save this for another question.
Refer to another question.
show NSUserNotification additionalActions on click
P.S. I am using El Capitan APIs

Detect button press from CLLocationManager Authorization alert

I am detecting whether the user has accepted the request to use location services in my app, I have a toggle switch in the UI that is dependent on this acceptance. The first time they toggle the switch (on) the request to use location is triggered. I want to know which button they press in that alert. (accept or decline) Right now I'm just toggling it off and making the user press it again (then detect which option they picked).
It is kind of sloppy that way, so I'd like to know if there is a way to detect this specific alert or can't that be done since it is triggered by the OS, not the application? I haven't tried it yet, but was thinking I could use the UIAlertView delegate methods for just generic button presses, but was hoping for something more specific.
UPDATE
I was able to get this working by just registering a notification when I trigger the location request (and the authorization prompt is shown). The application is placed in an inactive state (much like pulling down the notification bar). I just trigger a notification when the application becomes active and I'm able to just query the authorization status there and update my UI. I hope this helps anyone else down the line if they want to handle the authorization status on the fly.
There is no way to intercept the alert. There is, however, a method on CLLocationManagerDelegate method called didChangeAuthorizationStatus. That's probably the closest you can get to intercepting the alert.
There is no way to know explicitly which button the user selects since, as you've said, this alert comes from the OS. You can however, find out if location services has been enabled for your app, and know that way. Use a method such as this:
-(BOOL)locationServicesIsEnabled
{
if (![CLLocationManager locationServicesEnabled] || ![CLLocationManager authorizationStatus])
return NO;
return YES;
}

How to fire Local notification with custom view instead of default pop up according to set timer in iphone

Is there any standard step by step way to use the local notification in iPhone application.
I have never worked for local notification.
I am interested to use this to create a fake call.
So, i am interested to set the timer in the local notification & as per the timer i have to set the local notification with custom view instead of the default pop up of notification.
Please suggest me the standard way to deal with local notification.
Every type of suggestions & links are appreciable in advance.
Thanks.
You can't customize the local notification alert. I have also once searched for this. Alternatively I ended with showing the custom alert when the user accepts the local notification (similar to 2Do:Task done in style application).