I cannot get CMMotionActivityManager.startActivityUpdates() to work. I have given my app permission to use core motion and also put the required description key into my Info.plist file.
I am expecting my user to walk. I call startActivityUpdates() and then stand up and start walking. I typically get about 3 callbacks within a couple of seconds, all of which have "false" set for all of the activity flags, even "unknown". Then after that I get nothing.
I can't figure out what I could possibly be doing wrong here. The code is really simple. I looked at doezens of examples and my code is doing the exact same things.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm trying to use CMAcceleration data in my app to detect when the user is doing certain kinds of activities.
The problem I'm having is that the acceleration data for the same user motions is different depending on how they are holding their phone. I don't care about the orientation of the phone, I just care about the overall motion of the person holding it.
I've researched and tried a whole bunch of ways to correct the data for phone orientation, such as rotating the acceleration using the CMAttitude rotation matrix, removing the effect of gravity with a series of calculations, and doing both of these in both orders. I can't seem to come up with something that works.
I think there has to be some solution since iOS can do things like step counting which I assume doesn't depend on the orientation of the phone.
Thanks,
Frank
I was added to a team yesterday as a Developer. I can see this team when I log in to App Store Connect, but it does not appear on the Teams list in Xcode. How do I get Xcode to refresh this list?
You used to be able to use the "User Defined Runtime Attributes" section in Interface Builder to add attributes such as layer.borderColor, layer.borderWidth, layer.cornerRadius, etc. I can still enter these values, but they don't do anything. What happened?
I can still set them via code and then they work, but it's much more convenient to be able to do it in interface builder.
Topic:
UI Frameworks
SubTopic:
UIKit
Hi,My app is configured to receive location updates while running in the background.I need to send these updates to a server. I'd like to do it as soon as possible, but it isn't absolutely necessary.If I receive a location update in the background, am I allowed to send the data to a server immediately using an NSURLRequest? Do I need to call "beginBackgroundTaskWithExpirationHandler" to request time for the request to complete?Or, should I just store the location update in a local database and send it when the app is running in the foreground?I'm assuming that I can use an expression such as "[[UIApplication sharedApplication] applicationState] != UIApplicationStateActive" in my CLLocationManagerDelegate callback to determine whether I'm getting locations in the background.Thanks!
Hi,According to the documentation for the AVVideoCompositing protocol:"When creating instances of custom video compositors, AV Foundation initializes them by calling init and then makes them available as the value of the customVideoCompositor property of the object to which it was assigned. You then can do any additional setup or configuration to the custom compositor."AVMutableVideoComposition has a customVideoCompositorClass property, but does not have a customVideoCompositor property.Am I misunderstanding this? I need to access the instance to set some properties on it, but I cannot.Thanks,Frank
Hi,The UIWebView class has a convenient property called scalesPageToFit, which can be used to allow small web pages to scale automatically to fit the frame of the web view.But this class is now deprecated in favor of WKWebView, which doesn't seem to have an equivalent property. How do I get the same functionality with WKWebView?Thanks,Frank
Is there a way I can detect at runtime whether the app was installed from Test Flight vs. App Store?Frank
Whenever I try to upload an app from Xcode, I get this error right as the file upload begins:
App Store Connect Operation Error
An error occurred uploading to the App Store.
This is not a transient problem. I have had this issue for months, ever since I started using an M1 Mac Mini for most of my development.
The only workaround I've been able to find so far is to use a different Mac to upload my builds. Luckily, I have another one, but I'm getting tired of doing this.
Both Macs are running the same version of Mac OS, same version of Xcode, and are on the same Wifi network. I also checked to make sure the network settings are identical.
How can I debug this problem?
I've got a fairly old app that I first built back in 2014, and have been maintaining over the years.
One of the screens in the app uses the camera to scan barcodes. The barcodes we scan are printed on labels, and are in the org.iso.Code128 format.
When the app was first developed, I simply set the metadataObjectTypes property of AVCaptureMetadataOutput to all available types. This worked fine. The app scanned our barcodes very quickly with almost no issues.
In 2017, we started seeing issues where barcode scanning was becoming slower. I reasoned that having it configured to scan for every possible barcode format might be the issue, so I went in and changed the code to have it scan only for the org.iso.Code128 format. This helped, for a while.
Now, we're seeing the problem again in iOS 14 devices. On some devices it is nearly impossible to scan the barcodes. On others, you have to wait 20 or 30 seconds before the barcode is recognized.
What could be causing this issue?
I happen to have a lot of experience writing a Windows application in c#, where the async/await pattern has been a standard feature for years.
I can say from this experience that it's a great way to handle concurrency and I'm really happy that Apple is bringing this to Swift.
I'm often critical of language improvements that end up reproducing things you could already do with a different syntax, but in this case it's definitely worth it.
If you've never used async/await, it may initially look confusing. It looks like all you're doing is blocking your thread from running until another thread completes, but what really happens is that your thread returns at the point where the await keyword appears, and then resumes later when the result is available. So if your thread is the main thread, which is the most common case, using await doesn't block the main thread.
Exactly how the compiler manages to suspend and resume the thread without destroying your local variables, I don't know, but I'm sure they figured out a way that makes sense.
Frank
Hi,
I'm trying to figure out how to manually position a subview within a view using SwiftUI.
For example, when the user taps the screen, I want to place a small icon on the screen at the position tapped.
I know how to get the coordinates of the tapped location but I don't know how to either place a view there or move an existing view already being shown to that location.
In a regular non-SwiftUI app I can set the frame, or set up constraints. I don't know what the best approach is in SwiftUI.
Thanks.
Hi,
I've been asked to estimate a project that would require ARKit, unfortunately I'm new to the technology and need some quick answers as to how it works.
The app my customer wants to build would overlay simple graphics at street addresses, as the user pointed their camera at buildings or storefronts.
For this to work, I'd need to be able to have the AR view tell me what map locations or street addresses are being seen in the camera view. Is this possible?
Thanks,
Frank
Is there any way to scan for Bluetooth advertising messages while in the background if the device doesn't advertise any service IDs?
I've been asked to build and app that does this. The device in question is an off-the-shelf medical alert button (my company doesn't make the device and can't alter its firmware). Upon examining it, I find that it does not advertise any service IDs nor does it offer any ability to connect, it works purely by sending advertising packets.
I'm told that there are Android apps that can work with this device even while in the background. I checked the iOS bluetooth docs to see if any new scanning capabilities had been recently added, but could not find anything.
Thanks,
Frank
Hi,
I'm looking at the function activityViewController(_:dataTypeIdentifierForActivityType:) in the UIActivityItemSource protocol. The documentation says "For items that are provided as data, returns the UTI for the item." The return type of the function is a String.
I don't know what "UTI" means in this context. The data I'm trying to provide is an HTML document (a string containing HTML). I tried returning "text/html", but I don't think this worked.
I'm also unsure whether my "itemForActivityType" function ought to be providing the HTML as a String, or perhaps converting it to Data first.
The end result I'm seeing is that I can share the HTML document via Mail, and it looks fine, but if I try to air drop it, I get an error that says "Extension request contains input items but the extension point does not specify a set of allowed payload classes."
I'd like my app to be able to share the HTML document via Mail or Airdrop. I don't care if it doesn't support sharing to any other services.
Thanks,
Frank