I would like to implement the same kind of behavior as the Dropoverapp application, specifically being able to perform a specific action when files are dragged (such as opening a window, for example).
I have written the code below to capture the mouse coordinates, drag, drop, and click globally. However, I don't know how to determine the nature of what is being dropped. Do you have any ideas on how to detect the nature of what is being dragged outside the application's scope?
Here is my current code:
import SwiftUI
import CoreGraphics
struct ContentView: View {
@State private var mouseX: CGFloat = 0.0
@State private var mouseY: CGFloat = 0.0
@State private var isClicked: Bool = false
@State private var isDragging: Bool = false
private var mouseTracker = MouseTracker.shared
var body: some View {
VStack {
Text("Mouse coordinates: \(mouseX, specifier: "%.2f"), \(mouseY, specifier: "%.2f")")
.padding()
Text(isClicked ? "Mouse is clicked" : "Mouse is not clicked")
.padding()
Text(isDragging ? "Mouse is dragging" : "Mouse is not dragging")
.padding()
}
.frame(width: 400, height: 200)
.onAppear {
mouseTracker.startTracking { newMouseX, newMouseY, newIsClicked, newIsDragging in
self.mouseX = newMouseX
self.mouseY = newMouseY
self.isClicked = newIsClicked
self.isDragging = newIsDragging
}
}
}
}
class MouseTracker {
static let shared = MouseTracker()
private var eventTap: CFMachPort?
private var runLoopSource: CFRunLoopSource?
private var isClicked: Bool = false
private var isDragging: Bool = false
private var callback: ((CGFloat, CGFloat, Bool, Bool) -> Void)?
func startTracking(callback: @escaping (CGFloat, CGFloat, Bool, Bool) -> Void) {
self.callback = callback
let mask: CGEventMask = (1 << CGEventType.mouseMoved.rawValue) |
(1 << CGEventType.leftMouseDown.rawValue) |
(1 << CGEventType.leftMouseUp.rawValue) |
(1 << CGEventType.leftMouseDragged.rawValue)
// Pass 'self' via 'userInfo'
let selfPointer = UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
guard let eventTap = CGEvent.tapCreate(
tap: .cghidEventTap,
place: .headInsertEventTap,
options: .defaultTap,
eventsOfInterest: mask,
callback: MouseTracker.mouseEventCallback,
userInfo: selfPointer
) else {
print("Failed to create event tap")
return
}
self.eventTap = eventTap
runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0)
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, .commonModes)
CGEvent.tapEnable(tap: eventTap, enable: true)
}
// Static callback function
private static let mouseEventCallback: CGEventTapCallBack = { _, eventType, event, userInfo in
guard let userInfo = userInfo else {
return Unmanaged.passUnretained(event)
}
// Retrieve the instance of MouseTracker from userInfo
let tracker = Unmanaged<MouseTracker>.fromOpaque(userInfo).takeUnretainedValue()
let location = NSEvent.mouseLocation
// Update the click and drag state
switch eventType {
case .leftMouseDown:
tracker.isClicked = true
tracker.isDragging = false
case .leftMouseUp:
tracker.isClicked = false
tracker.isDragging = false
case .leftMouseDragged:
tracker.isDragging = true
default:
break
}
// Call the callback on the main thread
DispatchQueue.main.async {
tracker.callback?(location.x, location.y, tracker.isClicked, tracker.isDragging)
}
return Unmanaged.passUnretained(event)
}
}
App Tracking Transparency
RSS for tagRequest user permission to access user data for tracking a user or device.
Posts under App Tracking Transparency tag
70 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Have anyone seen a orange microphone logo open on the dynamic island, and after you click on it opens a accessibility app with the black screen?
I have been eagerly awaiting the activation and granting of access to the image creation tool for the past two days, in order to explore the potential opportunities for service provision. Could anyone kindly assist me with this matter?
Playground long time 24h don’t early access request ed
I´m working within the health felid with a few apps. Accordingly to science one of the most important parts to keep healthy is every day walking.
But it is not to walk slow. You need to come to a little speed (not running or even jogging). But to rais your puls. This is when you get the "real health effect". In general it is around 6km/h.
It would be great if apple could make this info available for us developers. I think lots of developers will be happa and use this to make better apps and get more people in a healtheyer life.
Looking forward to get some feedback on this.
Thank you!
Cheers
Peter
please check and help me how to finish it.
Phone Pe's customer support:09798-179-306
app migration has been found to cause a change in the team ID. The Associated Domians section of Xcode includes the team ID. If the transfer is completed, will the team ID that has already installed my Nanjing app automatically change? If not, how can I ensure compatibility between the new and old versions
Hello, I have a question regarding the voice and sound recognition features on the iPhone 15 Pro.
The iPhone 15 Pro is equipped with four microphones, and I understand that for features like Apple’s sound recognition and when invoking Siri, the microphone(s) must always be active. My question is whether the device uses a single microphone (mono channel) for these functions or if multiple microphones are activated simultaneously.
I would appreciate clarification on how the microphones are utilized in sound and voice recognition features.
Thank you for your assistance.
Best regards.
Hello, I have a question regarding the voice and sound recognition features on the iPhone 15 Pro.
The iPhone 15 Pro is equipped with four microphones, and I understand that for features like Apple’s sound recognition and when invoking Siri, the microphone(s) must always be active. My question is whether the device uses a single microphone (mono channel) for these functions or if multiple microphones are activated simultaneously.
I would appreciate clarification on how the microphones are utilized in sound and voice recognition features.
Thank you for your assistance.
Best regards.
Long story short. My app tracks users via cookies and allows them to see relevant ads and such.
Apple wants me to implement App Tracking via Xcode.
The issue is I am running on Windows OS and do not have the ability to make the changes needed to get this app approved.
The app was built through a 3rd party app building site, and they have no solutions at this time.
So not unless someone has an idea on how to make these changes myself, I am all ears.
To refund money from Phone Pe for a wrong transaction, you should immediately contact Phone Pe's customer support:09738-149-306-and (available 24/7) report the issue.
在idea中Java spring 框架如何运行啊,求求大佬们,我跑https://gitee.com/lab1024/smart-admin 这个包老是报错,不让我写入
Hello
I have an app that uses the user's Device ID for tracking purposes.
I have since removed all ads and tracking.
I am now in a difficult position because I cannot turn off Device ID Tracking from App Privacy. The current app version has this on and contains the framework for turning it on.
If I try to submit an app without Tracking, it gets rejected with the message "The app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 18.0."
So, I am now stuck.
I cannot turn off Device Tracking in App Privacy because my app previously had tracking.
I cannot remove the framework for Tracking because App Privacy has tracking on.
How can I proceed to remove all tracking traces from my app?
Jake
The app does not meet all requirements for apps that offer highly regulated services or handle sensitive user data. Specifically:
The account that submits the app must be enrolled in the Apple Developer Program as an organization, and not as an individual.
The guideline 5.1.1(ix) requirements give users confidence that apps operating in highly regulated fields or that require sensitive user information are qualified to provide these services and will responsibly manage their data.
Next Steps
To resolve this issue, it would be appropriate to take the following steps:
The app must be submitted through an Apple Developer Program account enrolled as an organization. You may either enroll in a new Apple Developer Program account as an organization, or request that your individual account be converted to an organization account by contacting Apple Developer Support.
Please note that you cannot resolve this issue with documentation showing permission to publish this app on behalf of the content owner or institution.
Resources
Learn how to transfer apps between accounts.
Request a fee waiver for nonprofit organizations, accredited educational institutions, or government entities.
Support
Reply to this message in your preferred language if you need assistance. If you need additional support, use the Contact Us module.
Consult with fellow developers and Apple engineers on the Apple Developer Forums.
Help improve the review process or identify a need for clarity in our policies by suggesting guideline changes.
Request a phone call from App Review
At your request, we can arrange for an Apple Representative to call you within the next three to five business days to discuss your App Review issue.
Request a call to discuss your app's review
please how can i go about this
Hi all
can anyone check if my developer option is on or off?
as I dont know one of my friends hack or cloned my phone as whenever or where I go he got to know?? also my all icloud data
and sometime my phone looks completely chnaged ..
so can you check and advice what all i can do
I have already changed password multiple time... applied 2way authentication....
I just want to know who has done it... if anyone help me then he or she can use my iphone in anyway.
please help me
Thanks
Chetan
Hello, We are currently using App tracking transparency in the app. Is this specification of Apple? While showing ATT permission dialog, the app cannot be a background?
Is it possible to close the dialog without selecting Allow or Deny?
Hello, We are currently using App tracking transparency in the app.
Is this specification of Apple what is while showing ATT permission dialog, the app cannot be a background?
Is it possible to close the dialog without selecting Allow or Deny?
Hi,
Is there anyway to see where an app is, like is it in the top 30, or 10? If not, that would be a nice add-on so we can really get an idea of if our app really stinks or not :-)
Thanks,
Dan Uff
I have an issue with web ads not working in Safari versions earlier than 16.4.
While debugging Safari Web Ads I found out that I don't get postbacks from versions 16.4 or below from Safari, although there are no technical limitations and the documentation says that web ads should work starting from versions 16.1 https://developer.apple.com/documentation/storekit/skadnetwork/skadnetwork_release_notes/skadnetwork_4_release_notes
For ads that appear in an app, the app is built with iOS 16.1 SDK or later. For web ads, the ad appears in Safari 16.1 or later.``
Maybe I missed something and Apple didn't update the documentation, is that normal?
Maybe it's related to this release and there was a technical problem with Apple? https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16_4-release-notes/#SKAdNetwork
Has anyone encountered the same problem and how did you fix it?
Thanks!