Posts

Post not yet marked as solved
0 Replies
357 Views
When my SwiftUI based watch app responds to an WKSnapshotRefreshBackgroundTask, how do I change the navigation stack? Before using SwiftUI we'd just do this: if let root = WKExtension().shared.rootInterfaceController { 		root.pushController(withName: "Controller1", context: nil) 		root.pushController(withName: "Controller2", context: nil) } And now I'd have the screen I wanted. Not sure how to accomplish that same thing with SwiftUI
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
387 Views
In my view I've done this: var body: some View {   TabView {     DayView(summary: History.shared.today())     DayView(summary: History.shared.thisWeek())     DayView(summary: History.shared.thisMonth())   }   .tabViewStyle(PageTabViewStyle()) } how do I tell the appropriate DayView when it has become the active page? If it matters for implementation, this is specifically when using WatchOS.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
264 Views
When I run my app on my device and send a push notification, the custom UI shows up and the custom actions appear as well. By custom actions I med the UNNotificationAction items. If, however, I run on the simulator, that doesn't work. When I drag my payload onto the simulator the notification shows and on long-press I see the custom UI, but I don't see any of the custom buttons. Is this a known bug?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
222 Views
In my didReceive(_:withContentHandler:) method I'm trying to download a file. I get the URL of the mp4 file I want to download and then do this: bestAttemptContent.body = "I'm here" do {	 	let data = try Data(contentsOf: url) } catch { 	bestAttemptContent.body = error.localizedDescription } The body isn't modified at all when I do a file download like that. If I comment out line 4, the body is updated as expected. I verified that it's not timing out because the serviceExtensionTimeWillExpire method changes the title so I know a timeout happened and that's not the case. In the debugger I verified the URL is exactly what was passed as part of the payload, and I've verified that URL is correct. If I try to step over line 4 in the debugger it just goes into assembly code and never moves on. The file only takes a few seconds to download from my mac. Both the main project and the service extension allow insecure loads from the net. Any thoughts on why it seems to abort and yet not simply move into the catch block as expected?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
250 Views
I've got a simple app delegate method to create a core data object when my push notification arrives. The save() is returning nilError and I can't figure out what I'm doing wrong. I've verified all the elements of Message have expected data. The attributes are just String, Data, and Date types. class AppDelegate: NSObject, UIApplicationDelegate {  @Environment(\.managedObjectContext) private var managedObjectContext   func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {   guard let text = userInfo["text"] as? String,      let image = userInfo["image"] as? String,      let url = URL(string: image) else {    completionHandler(.noData)    return   }   let context = self.managedObjectContext   URLSession.shared.dataTask(with: url) { data, response, error in    guard let data = data, error == nil else {     completionHandler(.failed)     return    }    context.perform {     let message = Message(context: context)     message.text = text     message.image = data     message.received = Date()     do {      try context.save()      completionHandler(.newData)     } catch {      print(error)      completionHandler(.failed)     }    }   }.resume()  }
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
899 Views
I've got a simple data model that includes a PassthroughSubject like so:final class PeopleDataModel: NSObject, ObservableObject { var didChange = PassthroughSubject<Void, Never>() private lazy var fetchedResultsController: NSFetchedResultsController<Person> = { ... }() public var people: [Person] { return fetchedResultsController.fetchedObjects ?? [] } } extension PeopleDataModel: NSFetchedResultsControllerDelegate { func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { people.forEach { print($0) } didChange.send() } }So my intent is when Core Data is updated, it'll send the message out. Now I try and use it in my SwiftUI view:struct ContentView : View { @ObservedObject var peopleDataModel = PeopleDataModel() var body: some View { NavigationView { List(peopleDataModel.people) { person in NavigationLink(destination: PersonDetailView(person: person)) { PersonRow(person: person) } } .navigationBarTitle(Text("People")) } } }The view doesn't actually update with the people that have been inserted into Core Data. They show properly in the print from the data model, but don't appear in the List. How do I actually "tie" these things together so that when Core Data updates the List knows that it needs to redraw itself?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
I've got an NSPopupButton where I bound the Content property to my array controller's arrangedObjects, with a model key path of 'name'. If I click on the popup, it correctly shows all of the names I expect to see. When I then select one of those names, nothing happens. The list goes away as expected, but the displayed name is still the first item in the list.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
801 Views
I have an attribute on my entity with a Transformable type. It's not optional, but I don't see any way to specify a default value. Since I'm using CloudKit it's failing because there's not a default value specified. How do I provide a default value since the attribute inspector doesn't give a field for that when it's a Transformable?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
137 Views
I'm really confused by how to use SIWA on a website. My angular web client has the button and once clicked Apple redirects to the URL I've specified, which is my Vapor webservice. That validates the token passed in with Apple's JWK, so now I know the client is authenticated. Then I'd create the token to use for subsequent Authorization headers...how do I get that back to the client now? I feel like I'm doing something wrong here.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
When sending a JSON payload, sometimes it's important to know whether a null value was sent, especially for a PATCH type operation. The struct that I decode to will obviously have that as a nullable type. However, I can't see any way to know whether it's nil because the JSON contained the key with a null value, or whether it's nil because the JSON just didn't send that key. How do you handle this?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
5 Replies
520 Views
I'm trying to make a loyalty card where you get 10 punches and then $5 off your next order. I can get the card into Wallet without issues, and I have the push notifications working to send a new version of the pass to the device. What i'm not sure how to handle though is actually "punching" the card.The only thing I can come up with is to have the pass contain a barcode that the vendor scans with their phone and that would take them to some type of webpage where the vendor types in their password and "punches" the card. That seems really cumbersome though to do. Is there a better way for the vendor to update the card without having to pull out an iOS device?Same with the $5 off coupon. Do they scan a barcode on the wallet pass and then mark it as being used, and the server then pushes a $0 update for that card back?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
2 Replies
525 Views
I know how to do a wallet loyalty card but how do I tie that to Apple Pay? For example, I went to Jimmy John’s today and when I used Apple Pay (not in the app) it automatically applied my loyalty card.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
311 Views
I'm watching the Sign in with Apple tutorial over and over, and looking at the Juice sample app, and I'm just not seeing where ASPasswordCredential comes into play. I understand it's called via ASAuthorizationPasswordProvider but where is it getting the username and password from? They generically say "icloud keychain". With a keychain item you generally have a service, account, and optional access group. How do I know what to set those three things to so that Apple knows exactly what is my username and what is my password?
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
0 Replies
335 Views
How do I change the root view of my SwiftUI app? For example, normally in the SceneDelegate I'd display my ContentView() as the root view to the hosting controller. But depending on conditions I might want to display something else first, like a LoginView, and then when that view goes away show the normal ContentView.
Posted
by Gargoyle.
Last updated
.
Post not yet marked as solved
3 Replies
548 Views
When I go to create a service for sign in with apple (to use with a webapge) on the Certificates, Identifiers & Profiles page, the configuration is very confusing. It says to click the download button but there isn't one. Where it asks for my domain I enter it and when I hit save it just tells me it not a valid domain...which it definitely is. Is there documentation somewhere showing how to configure this?
Posted
by Gargoyle.
Last updated
.