I have a SwiftUI app. It fetches records through CoreData. And I want to show some records on a widget. I understand that I need to use AppGroup to share data between an app and its associated widget.
import Foundation
import CoreData
import CloudKit
class DataManager {
static let instance = DataManager()
let container: NSPersistentContainer
let context: NSManagedObjectContext
init() {
container = NSPersistentCloudKitContainer(name: "DataMama")
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group identifier)!.appendingPathComponent("Trash.sqlite"))]
container.loadPersistentStores(completionHandler: { (description, error) in
if let error = error as NSError? {
print("Unresolved error \(error), \(error.userInfo)")
}
})
context = container.viewContext
context.automaticallyMergesChangesFromParent = true
context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyObjectTrumpMergePolicyType)
}
func save() {
do {
try container.viewContext.save()
print("Saved successfully")
} catch {
print("Error in saving data: \(error.localizedDescription)")
}
}
}
// ViewModel //
import Foundation
import CoreData
import WidgetKit
class ViewModel: ObservableObject {
let manager = DataManager()
@Published var records: [Little] = []
init() {
fetchRecords()
}
func fetchRecords() {
let request = NSFetchRequest<Little>(entityName: "Little")
do {
records = try manager.context.fetch(request)
records.sort { lhs, rhs in
lhs.trashDate! < rhs.trashDate!
}
} catch {
print("Fetch error for DataManager: \(error.localizedDescription)")
}
WidgetCenter.shared.reloadAllTimelines()
}
}
So I have a view model that fetches data for the app as shown above.
Now, my question is how should my widget get data from CoreData? Should the widget get data from CoreData through DataManager? I have read some questions here and also read some articles around the world. This article ( https://dev.classmethod.jp/articles/widget-coredate-introduction/ ) suggests that you let the Widget struct access CoreData through DataManager. If that's a correct fashion, how should the getTimeline function in the TimelineProvider struct get data? This question also suggests the same. Thank you for your reading my question.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I submitted a new app in the morning of December 30th, last year. A reviewer picked it up 2 days ago and then rejected it by saying that the Send button remains disabled. Of course, it remains disabled because the user is supposed to select a message out of 300 of them.
The app comes with a how-to-use guide, which states that you need to select a message by tapping the Select button. Now, the reviewer is MIA. I don't necessarily blame the reviewer for not having read the user guide thoroughly. But I wonder why they don't just ask instead of jumping to a conclusion? They often reject the app for simple reasons these days. And they are often wrong. I understand that everybody makes a mistake. But they are wrong 4 out of 5 times. Last year, a reviewer rejected the app by saying that the user is not able to ask a question at the support site when in fact it was just the matter of scrolling down further. This is the type of reasons I strongly suggest they ask instead of jumping to a conclusion and then rejecting the app. It's quite difficult for me to make plans while dealing with reviewers if they are this sloppy.
Topic:
App Store Distribution & Marketing
SubTopic:
App Review
I nominated my app at the very end of the last year because I felt very good about it for the first time in my 16-year iOS app development history. But an unexpected rejection event has stricken it as depicted in this thread. It was approved 5 days ago. And I'm still furious about rejection because, as usual, they were wrong. Anyway, if I look under Nomination Details, it says that my last submission missed the boat. Is there anything that I can do after it missed the expected publish date?
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
I have an existing iOS app with MapKit. It always shows the current user location with UserAnnotation. But the same isn't true for macOS. I have this sample macOS application in SwiftUI. In the following, the current user location with a large blue dot appears only occasionally. It won't, 19 of 20 times. Why is that? I do have a location privacy key in Info.plist. And the Location checkbox is on under Signing & Capabilities.
import SwiftUI
import MapKit
struct ContentView: View {
@State private var markerItems: [MarkerItem] = [
MarkerItem(name: "Farmers Market 1", lat: 35.681, lon: 139.691),
MarkerItem(name: "Farmers Market 2", lat: 35.685, lon: 139.695),
MarkerItem(name: "Farmers Market 3", lat: 35.689, lon: 139.699)
]
@State private var position: MapCameraPosition = .automatic
var body: some View {
Map(position: $position) {
UserAnnotation()
ForEach(markerItems, id: \.self) { item in
Marker(item.name, coordinate: CLLocationCoordinate2D(latitude: item.lat, longitude: item.lon))
}
}
.mapControlVisibility(.hidden)
.mapStyle(.standard(elevation: .realistic))
.ignoresSafeArea()
}
}
#Preview {
ContentView()
}
struct MarkerItem: Hashable {
let name: String
let lat: Double
let lon: Double
}
I'm ready to submit a new app with 3 subscription plans. But the status of the group remains 'Prepare for Submission.' And it won't change. All the individual subscription plans have the 'Ready to Submit' status. I have triple-checked individual plans to see if there is anything missing. No. Nothing is missing. There are no pending business contracts to review, either. I have even deleted an existing group and created a whole new subscription group. And I still end up with this prepare status. Am I the only one having this subscription group difficulty?
One thing that I realize is that the status appears as 'Ready to Submit' on individual subscription plans. But their respective localization pair of display name and description get the Prepared status. The display name and the description fields are both filled for all three plans. What a nice, merry, merry Christmas.
I don't know what else I can do to resolve this Prepared madness. I've been stuck for 4 hours.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
Subscriptions
In-App Purchase
I have a desktop application that shows some real estate properties chosen by the user. The application shows those GPP locations on the map. The SwiftUI code is something like the following.
import SwiftUI
import MapKit
struct ContentView: View {
var body: some View
ZStack {
mapView
}
}
private var mapView: some View {
Map(position: $propertyViewModel.mapPosition) {
ForEach(propertyViewModel.properties) { property in
Annotation("", coordinate: CLLocationCoordinate2D(latitude: property.lat, longitude: property.lon)) {
Button {
} label: {
VStack {
Image(systemName: "house.circle.fill")
.resizable()
.scaledToFit()
.frame(width: 48)
.foregroundStyle(colorScheme == .light ? .white : .black)
...
}
}
.buttonStyle(.borderless)
}
}
UserAnnotation()
}
.mapControls {
MapUserLocationButton()
}
.mapControlVisibility(.visible)
.onAppear {
CLLocationManager().requestWhenInUseAuthorization()
}
}
}
The application only wants to use the CLLocationManager class so that it can show those locations on the map relative to your current GPS position. And I'm hit with two review rejections.
Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage
Issue Description
One or more purpose strings in the app do not sufficiently explain the use of protected resources. Purpose strings must clearly and completely describe the app's use of data and, in most cases, provide an example of how the data will be used.
Guideline 5.1.5 - Legal - Privacy - Location Services
The app uses location data for features that are not relevant to a user's location.
Specifically, the app is not functional when Location Services are disabled.
So I wonder if the application is even required to have 'NSLocationWhenInUseUsageDescription' and/or 'NSLocationUsageDescription'? just in order to show user's current location so that they can see property locations relative to it? The exact location privacy statement is the following.
The application needs your permission in accessing your current location so that it will appear on the map
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
MapKit
Privacy
SwiftUI
Maps and Location
I have a desktop application developed in SwiftUI that shows property locations on the map. That's NOT the main feature. IF you give the application permission to access your location, the blue dot will appear on the map. If you don't, the blue user dot won't appear. That's the only difference with location services. In other words, the application has no use of user's current position beyond showing it on the map. Since it's just the matter of showing or not showing the blue dot on the map, the application doesn't really need to use the location service. Anyway, the reviewer is talking about something else by rejecting the application in two aspects.
Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage
Guideline 5.1.5 - Legal - Privacy - Location Services
As I said earlier, the application only wants to show the blue dot on the map so that you can see your property locations relative to your current location. In code, it's something like the following.
Map(position: $propertyViewModel.mapPosition) {
ForEach(propertyViewModel.properties) { property in
Annotation("", coordinate: CLLocationCoordinate2D(latitude: property.lat, longitude: property.lon)) {
...
}
}
UserAnnotation()
}
So I'm hit with two rejection reasons with this one line.
UserAnnotation()
And the reviewer is talking about something like
the app is not functional when Location Services are disabled.
To resolve this issue, please revise the app so that the app is fully functional without requiring the user to enable Location Services.
Well, I can remove the UserAnnotation() line if I want to put this application through the review process. Nothing will become dysfunctional, though, if you decide to reject permission request. So
would you remove it
or would you play along with this reviewer
if you were me? It's been three or four days since rejection. As you can imagine, the reviewer doesn't bother to answer as to
What are the exact coordinates that the application has allegedly collected
What won't work as a result of location permission request refusal.
This isn't the first time I get my app rejected. I've probably had 150 to 200 of them rejected in the past 15 years. And just because a reviewer rejects your app for a bizarre reason, would you give in? Remove this feature and that feature because the reviewer is incompetent such that he or she makes his or her decision based on imagination? What do you think?
Topic:
App Store Distribution & Marketing
SubTopic:
App Review
Tags:
App Review
Privacy
SwiftUI
Maps and Location