Posts under App & System Services topic

Post

Replies

Boosts

Views

Activity

New features for APNs token authentication now available
Team-scoped keys introduce the ability to restrict your token authentication keys to either development or production environments. Topic-specific keys in addition to environment isolation allow you to associate each key with a specific Bundle ID streamlining key management. For detailed instructions on accessing these features, read our updated documentation on establishing a token-based connection to APNs.
0
0
1.3k
Feb ’25
Intermittently Transaction.latest(for:) api returns nil and unverified transaction
We are using method “Transaction.latest(for: productId)” to verify the transaction . Steps to reproduce : Step 1 : User made purchase for productId “product_id_one” Step 2 : “paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])” api returns successful purchase for product_id_one . func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { for transaction in transactions { switch transaction.transactionState { case .purchased: let mProductId = transaction.payment.productIdentifier Print(mProductId) // product_id_one .. Step 3: Call “Transaction.latest(for: product_id_one)” api . guard let verificationResult = await Transaction.latest(for: productId) else { // Here some times its returning nil for valid transaction return } switch verificationResult { case .verified(let transaction): // at time its working fine . we are getting verified purchase . // Check the transaction and give the customer access to purchased case .unverified(let transaction, let verificationError): // Here some times its returning unverified for valid transaction } Issue : For valid purchase , Sometimes Transaction.latest(for: productId) api is returning nil and unverified transaction . This is intermittent  issue.
0
0
321
Sep ’24
SwiftData: Predicate using optional Codable enum
Hello, I'm currently developing an app using SwiftData. I want the app to use CloudKit to sync data, so I made sure all my model properties are optional. I've defined a Codable enum as follows: enum Size: Int, Codable { case small case medium case large } I've defined a Drink SwiftData model as follows: @Model class Drink { var name: String? var size: Size? init( name: String? = nil, size: Size? = nil ) { self.name = name self.size = size } } In one of my Views, I want to use a @Query to fetch the data, and use a Predicate to filter the data. The Predicate uses the size enumeration of the Drink model. Here is the code: struct DrinksView: View { @Query var drinks: [Drink] init() { let smallRawValue: Int = Size.small.rawValue let filter: Predicate<Drink> = #Predicate<Drink> { drink in if let size: Size = drink.size { return size.rawValue == smallRawValue } else { return false } } _drinks = Query(filter: filter) } var body: some View { List { ForEach(drinks) { drink in Text(drink.name ?? "Unknown Drink") } } } } The code compiles, but when I run the app, it crashes with the following error: Thread 1: Fatal error: Couldn't find \Drink.size!.rawValue on Drink with fields [SwiftData.Schema.PropertyMetadata(name: "name", keypath: \Drink.name, defaultValue: nil, metadata: nil), SwiftData.Schema.PropertyMetadata(name: "size", keypath: \Drink.size, defaultValue: nil, metadata: nil)] How can I filter my data using this optional variable on the Drink model? Thanks, Axel
0
3
613
Oct ’24
error sharing url on cloudkit share
I'm studying sharing through this link. I followed the first steps by changing the bundle identifier of the project, the tests and placing my own container in the config and in the info.plist. https://github.com/apple/sample-cloudkit-zonesharing The app appears and in the log it appears that it has managed to access my iCloud, but when I click on share and share something, the following message appears in the console, on the simulator and on the iPhone: "No options were found, providing default value for access type" "No options were found, providing default values ​​for permissions" "connection invalidated" And finally, when I click on the shared link, the following message appears: "Item unavailable The owner stopped sharing, or you don't have permission to open it."
0
0
565
Sep ’24
Issue with Sandbox Account on iPhone (iOS) for In-App Purchase Testing
Hi everyone, I'm currently working on testing in-app purchases for my app, and I'm having issues with logging into a sandbox account on my iPhone. Here's the situation: I created a sandbox account via App Store Connect. I signed out of my regular Apple ID from the App Store and attempted to log in with my sandbox account during an in-app purchase. I receive a verification code on my phone, and it seems like the login is working. However, after entering the code, I keep getting redirected back to the "Sign in with Apple Account" screen. It doesn’t fully log me in. I’ve tried resetting network settings, restarting the device, and even creating a new sandbox account, but nothing seems to work. I'm running the app through Expo prebuild and attempting to test purchases, but without being able to log into the sandbox environment, I can’t move forward. Has anyone encountered this issue before or know how to fix it? Any help would be greatly appreciated! Thanks!
0
0
554
Sep ’24
Exporting/storing user HealthKit data for analytics in database
I am having trouble finding clear information about this. I want my app to collect and aggregate user data to provide useful analytics to the user and userbase. Can data accessed from HealthKit be stored on a database outside the Apple ecosystem and used for analytics? The data will not be used for marketing and will not be shared. It will be used only for the benefit of the user's understanding of their health and for the community that uses the app. If not, what if the data is anonymized first before being exported to a 3rd party database?
0
0
403
Oct ’24
question about App Store Server Notifications
I have 2 subscriptions, monthly and year first:DID_CHANGE_RENEWAL_PREF + DOWNGRADE: Customer downgrades a subscription within the same subscription group; The current subscribe is year;if i change to month;when the subscribe year was expire,Automatic renewal will change to month second:DID_CHANGE_RENEWAL_PREF+UPGRADE: Customer upgrades a subscription within the same subscription group. The current subscribe is month;if i change to year;I need to pay for the annual subscription immediately;and The subscription immediately switches to the annual third:DID_CHANGE_RENEWAL_PREF subtype is None Customer reverts to the previous subscription, effectively canceling their downgrade. what this mean? This is Test Env,month is five minutes;year is one hour ①My current subscription is an annual, startTime:2024-10-02 15:04:58 ,expireTime:2024-10-02 16:04:58 ②first DOWNGRADE to month,at 2024-10-02 15:14:16 ②after 38 minutes,I change to the annual subscribe;at 2024-10-02 15:52:00 in the end,the Notification purchaseDate 2024-10-02 15:52:00;expiresDate 2024-10-02 16:52:00; So When I get NotificationType=DID_CHANGE_RENEWAL_PREF,NotificationSubType=None,Do I need to create a new subscription for the users? Is it the latest notice of purchaseDate and expiresDate, for a year? The appleNotification Payload as follows: JWSTransactionDecodedPayload( originalTransactionId='2000000731045285', transactionId='2000000731088945', webOrderLineItemId='2000000076096676', bundleId='app.xxxx', productId='com.xxxx.365', subscriptionGroupIdentifier='21514251', purchaseDate=1727855520000, 2024-10-02 15:52:00 originalPurchaseDate=1727852699000, 2024-10-02 15:04:59 expiresDate=1727859120000, 2024-10-02 16:52:00 quantity=1, type=<Type.AUTO_RENEWABLE_SUBSCRIPTION: 'Auto-Renewable Subscription'>, rawType='Auto-Renewable Subscription', appAccountToken='fa37b7a2-2b0b-43cb-8fda-a1fb21168efe', inAppOwnershipType=<InAppOwnershipType.PURCHASED: 'PURCHASED'>, rawInAppOwnershipType='PURCHASED', signedDate=1727855526632, 2024-10-02 15:52:06 revocationReason=None, rawRevocationReason=None, revocationDate=None, isUpgraded=None, offerType=None, rawOfferType=None, offerIdentifier=None, environment=<Environment.SANDBOX: 'Sandbox'>, rawEnvironment='Sandbox', storefront='CAN', storefrontId='143455', transactionReason=<TransactionReason.PURCHASE: 'PURCHASE'>, rawTransactionReason='PURCHASE', currency='CAD', price=14990, offerDiscountType=None, rawOfferDiscountType=None) JWSRenewalInfoDecodedPayload( expirationIntent=None, rawExpirationIntent=None, originalTransactionId='2000000731045285', autoRenewProductId='com.xxxx.365', productId='com.xxxx.365', autoRenewStatus=<AutoRenewStatus.ON: 1>, rawAutoRenewStatus=1, isInBillingRetryPeriod=None, priceIncreaseStatus=None, rawPriceIncreaseStatus=None, gracePeriodExpiresDate=None, offerType=None, rawOfferType=None, offerIdentifier=None, signedDate=1727855526632, 2024-10-02 15:52:06 environment=<Environment.SANDBOX: 'Sandbox'>, rawEnvironment='Sandbox', recentSubscriptionStartDate=1727852698000, 2024-10-02 15:04:58 renewalDate=1727859120000, 2024-10-02 16:52:00 currency='CAD', renewalPrice=14990, offerDiscountType=None, rawOfferDiscountType=None, eligibleWinBackOfferIds=None)
0
0
416
Oct ’24
Missing manual - Training Load, .estimatedWorkoutEffortScore, .workoutEffortScore - Where are the Apple RPE CR-10 scale docs?
Apple is using the RPE scale for workout effort scores. This stands for the Rate of Perceived Exertion. They're specifically using the CR-10 scale, at least from what I can tell by saving values to HealthKit. They only accept value between 0 and 10. Has anyone been able to find a scientific or academic paper on how they have chosen their different effort breakouts? Right from the Fitness app on iPhone and Activity app on Apple Watch: 1-3 Easy 4-6 Moderate 7-8 Hard 9-10 All Out There is zero documentation on these new types, which makes it difficult for workout recording apps to properly and appropriately save this new data type. Sure, we can use the Apple apps as a reference, but since there isn't a built-in Apple SwiftUI sheet to present this data, and no references to academia to point our users to, our solutions would just look the same. FB15315876 - Documentation / HealthKit: Publish documentation about .workoutEffortScore and .estimatedWorkoutEffortScore FB15316109 - Documentation / HealthKit: Add documentation to .estimatedWorkoutEffortScore and .workoutEffortScore that you can't save those samples via the save API and that they must be related and let that API save the sample FB15316251 - Documentation / HealthKit: Add documentation for acceptible values of .estimatedWorkoutEffortScore and .workoutEffortScore - don't rely on a runtime error! Apple missed making an enum for all third party developers this year.
0
1
652
Oct ’24
MKLocalSearch for cities - How to uniquely identify results?
I'm using MKLocalSearch with resultTypes set to .address to search for cities. The search results don't include an ID for each city, which I need for database storage (which from my understanding is the only thing we can store). If I can't store the city name, country, and coordinates in my database, and I'm not allowed to use third-party data (like a pre-made list of cities with coordinates), what are my options for uniquely identifying and storing these city results? Any suggestions would be greatly appreciated.
0
0
439
Oct ’24
Fulfilling a fault in Core Data throws an exception when app is in background
Hi, I have been looking into Core Data crashes happening when the app is in background and fault is fired due to some processing happening within the app. The stack looks like this where the line 5 just accesses a property of the NSManagedObject's subclass. Unfortunately I don't see any additional information about the exception itself. Therefore, I was wondering if anyone could shed some light on which exception the NSFaultHandler.m:395 is triggering and why. Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Triggered by Thread: 10 Last Exception Backtrace: 0 CoreFoundation 0x1d15b8e38 __exceptionPreprocess + 164 (NSException.m:202) 1 libobjc.A.dylib 0x1ca7478d8 objc_exception_throw + 60 (objc-exception.mm:356) 2 CoreData 0x1d8dda27c _PFFaultHandlerLookupRow + 2508 (NSFaultHandler.m:395) 3 CoreData 0x1d8e024e0 _PF_FulfillDeferredFault + 200 (NSFaultHandler.m:915) 4 CoreData 0x1d8eb8f1c _sharedIMPL_pvfk_core + 168 (NSManagedObject_Accessors.m:1198) 5 MyApp 0x103641928 closure #8 in static ChatChannel.create(fromDTO:depth:) + 304 (ChannelDTO.swift:531) At first I was thinking if this could be a case of accessing a deleted object while the context is still referencing it, but does not look like it. At least I can't reproduce it (tried deleting objects using a separate context and even with container but no crash happens). Happy to learn about different cases what could trigger exception with this stack. Notes: Contexts I use are all created with newBackgroundContext method.
0
0
346
Nov ’24
Issues with Apple Nearby Interaction app not detecting DWM3001CDK accessory
Hi everyone, I’m having trouble getting my iPhone 11 to detect a DWM3001CDK as an accessory using the Apple Nearby Interaction app. Here’s the background: Two years ago, I successfully tested UWB ranging between the same devices (iPhone 11 and DWM3001CDK, which is based on the Qorvo DW3110 IC and an nRF52833 SoC with Bluetooth 5.2). At that time, the Nearby Interaction app was in beta and worked well for my tests. Now, with the stable version of the app, I’m encountering an issue. Here’s what I’ve done so far: I erased the DWM3001C and flashed it with the Qorvo Nearby Interaction firmware (v3.2.0, "DWM3001CDK-QANI-FreeRTOS_full_QNI_3_0_0.hex") using J-Flash Lite V7.86g on Windows. With this configuration, I can connect the iPhone 11 to the accessory using the Qorvo NI apps, both in the foreground and background. However, when I compile and run the project "ImplementingSpatialInteractionsWithThirdPartyAccessories" (available on the Apple Developer website) on my iPhone 11 (running iOS 17.7), the app remains stuck on the "Scanning for accessory" screen and doesn’t find the device, even though I’ve given the app permission to use Bluetooth. Could this be due to an issue with the firmware I flashed on the DWM3001CDK, or might there be something else causing the problem? Any help or insights would be appreciated! Thanks in advance.
0
0
575
Oct ’24
How to remove Subscription from Review
The guidance provided only explains how to remove the entire app from review, but not how to remove a single subscription. Currently, I have one incorrect subscription that has been rejected due to localisation issues, and it is stuck in the "In Review" status. Unfortunately, I am unable to make changes to it. The correct subscription is in the "Waiting for Review" status, and while I am able to remove it, there is no need to do so. What I would like to do is remove the previous, incorrect subscription.
0
0
360
Nov ’24
Backup and Restore a Flutter SQLite database file to iCloud
I'm managing the database with SQLite in Flutter. I want to enable iCloud backup and restore on the Swift side when called from Flutter. I am using the following source code, but it is not working. What could be the cause? Could you provide a method and countermeasure? private func saveFileToICloud(fileName: String, localDatabasePath: String, result: @escaping FlutterResult) { guard let containerName = Bundle.main.object(forInfoDictionaryKey: "ICLOUD_CONTAINER_NAME") as? String else { result(FlutterError(code: "NO_ICLOUD_CONTAINER", message: "iCloud container is not available", details: nil)) return } guard let containerURL = FileManager.default.url(forUbiquityContainerIdentifier: containerName) else { result(FlutterError(code: "NO_ICLOUD_CONTAINER", message: "iCloud container is not available", details: nil)) return } let fileURL = containerURL.appendingPathComponent(fileName) let sourceURL = URL(fileURLWithPath: localDatabasePath) do { if FileManager.default.fileExists(atPath: fileURL.path) { try FileManager.default.removeItem(at: fileURL) } try FileManager.default.copyItem(at: sourceURL, to: fileURL) result("File saved successfully to iCloud: \(fileURL.path)") } catch { result(FlutterError(code: "WRITE_ERROR", message: "Failed to write file to iCloud", details: error.localizedDescription)) } } private func readFileFromICloud(fileName: String, localDatabasePath: String, result: @escaping FlutterResult) { let containerName = ProcessInfo.processInfo.environment["ICLOUD_CONTAINER_NAME"] guard let containerURL = FileManager.default.url(forUbiquityContainerIdentifier: containerName) else { result(FlutterError(code: "NO_ICLOUD_CONTAINER", message: "iCloud container is not available", details: nil)) return } let fileURL = containerURL.appendingPathComponent(fileName) let sourceURL = URL(fileURLWithPath: localDatabasePath) do { if FileManager.default.fileExists(atPath: sourceURL.path) { try FileManager.default.removeItem(at: sourceURL) } try FileManager.default.copyItem(at: fileURL, to: sourceURL) result("File restored successfully to sqlite: \(sourceURL.path)") } catch { result(FlutterError(code: "READ_ERROR", message: "Failed to read file from iCloud", details: error.localizedDescription)) } }
0
0
616
Oct ’24
iOS: Can third party app see USB descriptors?
We have a USB dongle that would like to connect to the iPhone for power (using USB-C). Since it is not MFi, we will then use bluetooth for communication between the dongle and an app. When doing bluetooth pairing between the dongle and iPhone, it would be ideal to only see the dongle that is plugged into the iPhone listed in the app. This is to avoid connecting to other dongles that may be in the area. We think this could be possible using USB descriptors. We assume the iPhone can read the USB descriptors for non-MFi dongles. Our question is, can our app see the USB-descriptors of the dongle? Is iOS able to pass that info to the app? Then, we could have a unique USB descriptor for each dongle and the app could only list bluetooth devices with that descriptor (effectively filtering out any other dongles in the area). Any help and/or feedback is greatly appreciated :)
0
0
370
Oct ’24
PDFKit PDFPage.setBounds(_:for:) returns unexpected results in Xcode16
In XCode15, if you specify mediaBox for PDFDisplayBox, the page will be shrunk to fit the specified range. However, in XCode16, the page is cropped to fit the specified range, as when cropBox is specified for PDFDisplayBox. I think it's a bug because the setBounds documentation hasn't been updated, but has anyone had the same problem? Please let me know if there are any workarounds.
0
1
524
Sep ’24
CloudKit sharing limits?
When you share records, they get put into a new zone. Creating a zone for the share makes sense to me, but I thought I read that there was a limit to the number of zones one could have (something like 1024). Does this mean a user can’t share more than 1024 separate items with 1024 different people? I assume any other items shared with the same group end up in an existing zone.
0
0
369
Oct ’24
ApplePay Integration Error
Hello ApplePay Support, I am integrating apple pay support on the following page but getting error. I have attached code files and video also about debug that code with different response print. Please check it and let me know where is issue. ApplePay Page: https://payment.bestgoodstudio.com/uk/pay/ JS Code: $(document).ready(function() { function setupApplePayButton() { var applePayButton = $('#apple-pay-button'); if (applePayButton.length) { applePayButton.on('click', function() { initiateApplePayPayment(); }); } } async function initiateApplePayPayment() { if (!window.ApplePaySession) { alert('Apple Pay is not supported in this browser/environment.'); console.error('Apple Pay is not supported in this browser/environment.'); return; } var request = { countryCode: 'GB', currencyCode: 'EUR', supportedNetworks: ['visa', 'masterCard', 'amex'], merchantCapabilities: ['supports3DS', 'supportsEMV', 'supportsCredit', 'supportsDebit'], total: { label: 'Elitelab Pte Ltd', amount: '2.50' } }; var session = new ApplePaySession(3, request); session.onvalidatemerchant = async function(event) { const validationURL = event.validationURL; alert("Validation URL received: " + validationURL); try { const response = await fetch('https://payment.bestgoodstudio.com/uk/pay/apple_pay_validation.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ validationURL: validationURL }) }); const responseBody = await response.text(); // Get raw text to print whole response alert("Validation Response (raw): " + responseBody); // Print raw response in alert if (response.ok) { const responseData = JSON.parse(responseBody); // Parse it if valid JSON alert('Validation Response (parsed): ' + JSON.stringify(responseData)); console.log('Merchant Validation Data:', responseData); if (session) { session.completeMerchantValidation(responseData); alert('Merchant validation completed.'); } } else { alert("Merchant Validation failed. HTTP Status: " + response.status); session.abort(); // Abort session if validation fails } } catch (e) { alert('Error during Merchant Validation: ' + e.message); console.error('Merchant validation error:', e); session.abort(); // Abort session on error } }; session.onpaymentauthorized = function(event) { var payment = event.payment; var paymentToken = payment.token.paymentData; alert("Payment authorized. Payment Data: " + JSON.stringify(payment)); console.log('Payment Authorized:', payment); processApplePayPayment(payment, function(success) { if (success) { session.completePayment(ApplePaySession.STATUS_SUCCESS); alert('Payment completed successfully.'); } else { session.completePayment(ApplePaySession.STATUS_FAILURE); alert('Payment failed.'); } }); }; session.oncancel = function(event) { alert("Session canceled: " + JSON.stringify(event)); console.log("Session canceled:", event); }; session.oncomplete = function(event) { alert("Session complete: " + JSON.stringify(event)); console.log("Session complete:", event); }; session.begin(); } function processApplePayPayment(payment, callback) { var postData = { paymentData: payment.token.paymentData, billingContact: payment.billingContact, shippingContact: payment.shippingContact }; $.ajax({ url: 'process_apple_pay.php', method: 'POST', data: JSON.stringify(postData), contentType: 'application/json', success: function(response) { alert("Payment Processing Response: " + JSON.stringify(response)); console.log("Payment Processing Response:", response); callback(response.success); }, error: function(error) { alert('Error processing payment: ' + JSON.stringify(error)); console.error('Error processing payment:', error); callback(false); } }); } setupApplePayButton(); }); PHP Code:
0
0
473
Oct ’24