OSX: Track mouse position when not the key application - macos

I am writing an OSX application in Swift and want to track the mouse position even when the application is not the key application. This code sequence works for my View, but the view stops receiving mouseMoved events when the application is no longer the main application:
window!.acceptsMouseMovedEvents = true
window!.makeMainWindow()
window!.makeKeyAndOrderFront(self)
window!.makeFirstResponder(self)
How do I continue to get the mouseMoved applications when my application is no longer key?

In order for it to work accessibility needs to be enabled or your app has to be trusted for accessibility. You can then call the method:
addGlobalMonitorForEventsMatchingMask(_:handler:)
This registers a handler method for the particular event type for which you want to receive notifications.
Here's Apple's documentation on monitoring events.

Related

Incoming call notification - Android/iOS

I am developing a voip based phone call app specially for video conferencing type calls. Everything works via normal push notifications.
how do I show incoming call screen with sound e.g.
I am trying to implement - https://developer.android.com/guide/topics/connectivity/telecom/selfManaged
not sure if I am in the right direction.
Note: I don't want to interrupt/intercept normal phone calls.
I have managed to implement this using combination of push notification, broadcast receiver, alarm service, setting window flags on activity with "FullScreenIntent".
"OnMessageReceived" set an alarm for x seconds (500ms) with Broadcast receiver
in receiver setup MainActivity intent and set flags "NewTask" and "frombackground"
In MainActivity - override "OnNewIntent", set the window flags
Window.AddFlags(WindowManagerFlags.KeepScreenOn);
Window.AddFlags(WindowManagerFlags.DismissKeyguard);
Window.AddFlags(WindowManagerFlags.ShowWhenLocked);
Window.AddFlags(WindowManagerFlags.TurnScreenOn);
Window.AddFlags(WindowManagerFlags.Fullscreen);
this will open the app in fullscreen and can be routed to appropriate page for custom UI

App close event in Ionic Windows 8.1 App?

I'm building a Windows 8.1 App using Ionic 3. In the app, the user would have to type in a lot of stuff. I want to avoid accidental closure of the app by clicking on 'X' button at the top right corner or by Alt+F4. When the user tries to close the app, is there a way to prevent the default behaviour of closing the app and instead ask a confirmation?
You must override the onbackbutton event to do this.
document.addEventListener('backbutton', function (evt) {
/* BackButton pressed: do nothing */
return;
}, false);
Do NOT use the method shown on that page to exit the app:
throw new Error('Exit'); // This will suspend the app BUT the store will reject it
If you do this to exit your app, it will be rejected by the Microsoft store. To exit the app, remove the event listener and let the backbutton event suspend the app normally.
There's no special event to indicate that the user has closed an app.
App Lifecycle docs for Windows Store Apps.
https://learn.microsoft.com/en-us/previous-versions/windows/apps/hh464925(v=win.10)?redirectedfrom=MSDN#app-close
When the user closes the app or moves the app to background, it enters into a Suspended State. Windows recommends saving user state when the app enters such a state. You can save data in that state thereby achieving the overall goal.

iOS 11 push notification banner now shown while app in foreground

In doing some testing on the iOS 11 preview, I've noticed that when I get push notifications while my app is foregrounded the OS displays the system notification that you normally only see when your app is not active.
I didn't see anything announced as having been changed, or any new APIs to change this behavior one way or another. Does anyone know or have links to documentation stating if this is intended, a bug, temporary, or what?
There's an option for showing Push Notifications in the foreground in UserNotification framework.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
Quoting the comment from the Framework:
The method will be called on the delegate only if the application is in the foreground. If the method is not implemented or the handler is not called in a timely manner then the notification will not be presented. The application can choose to have the notification presented as a sound, badge, alert and/or in the notification list. This decision should be based on whether the information in the notification is otherwise visible to the user.
This could be the place to start looking for the answer.

Open Apple Maps by tapping on a WKInterfaceMap in a dynamic notification

My Watch app receives push notifications containing location information and I use that info to show a WKInterfaceMap.
However, when I tap on the map in the notification dynamic interface, my app is opened instead of the Maps app.
I found this forum post stating:
There is no url to call at this time. The user tapping on a WKInterfaceMap object is the only way to launch the Maps app from yours.
Does anyone know why this does not work with WKInterfaceMap objects in a notification?
Since notifications are not interactive, it's not possible to trigger any object interaction in a dynamic notification. Tapping anywhere in the notification area will always launch your watch app.
This is briefly mentioned in the App Programming Guide, under Designing Your Dynamic Interface:
Tapping your notification interface launches the app, so notification interfaces should not contain interactive controls.

Scanning notification through WIA

I've registered to receive WIA notifications for all devices through RegisterEventCallbackInterface for WIA_EVENT_DEVICE_CONNECTED and WIA_EVENT_SCAN_IMAGE events. However I only receive notifications when scanner device is plugged in - I don't receive notification when I scan (for example with mspaint which uses WIA). Am I supposed to receive scanning notifications from applications or only when Scan button is pressed on a device? (I haven't tried the latter since I use a multifunction printer without Scan button). Is there any other way to be notified about successful scans through WIA? Thank you.
The notification API will just tell you if the button has been pushed. You can register a temporary or permanent (i.e launch an app) handler. If you're trying to scan you need to use Item.Transfer() or CommonDialog.ShowTransfer() from device.Items[1].

Resources