Hi,
I want to generate some sample datas for demonstrating the functions of my app when the app launched. My codes are as followings:
func generateSampleData() {
let hasLaunchedKey = "HasLaunchedBefore"
let defaults = UserDefaults.standard
if !defaults.bool(forKey: hasLaunchedKey) {
//generate the demo data
}
defaults.set(true, forKey: hasLaunchedKey)
}
And I put the func in a view's onAppear modifier. I found every time I go the view, it generates the demo data again, which results in producing a lot of demo data. But I have set the status of the function running in the userdefault. Why did it happen?
Best Wishes,
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi, Dear Sir/Madam,
I released the Chinese version of my app and it has got approval from Apple reviewer on last Friday. But I can't find it by searching the Chinese keyword of my app in Chinese Apple store market till this Monday. I have checked my app and found that the name and other information of the app has been correctly localized. Why can't I find it? Look forward to your reply.
Best Wishes,
Topic:
App Store Distribution & Marketing
SubTopic:
General
Hi,
I have developed an app which has two in-app purchase subscriptions. During the test, the app can successfully get the status of the subscriptions. After it's released, I downloaded it from app store and subscribed it with my apple account. I found that in most cases, the app can identify that I have subscribed it and I can use its all functions. But yesterday, when I launched it again, it showed the warning that I haven't subscribed it. I checked my subscription in my account and the subscription status hasn't been changed, that is, I have subscribed it. And after one hour, I launched it again. This time the app identified that I have subscribed it. Why? The following is the code about listening to the subscription status. Is there any wrong about it?
HomeView()
.onAppear(){
Task {
await getSubscriptionStatus()
}
}
func getSubscriptionStatus() async {
var storeProducts = [Product]()
do {
let productIds = ["6740017137","6740017138"]
storeProducts = try await Product.products(for: productIds)
} catch {
print("Failed product request: \(error)")
}
guard let subscription1 = storeProducts.first?.subscription else {
// Not a subscription
return
}
do {
let statuses = try await subscription1.status
for status in statuses {
let info = try checkVerified(status.renewalInfo)
switch status.state {
case .subscribed:
if info.willAutoRenew {
purchaseStatus1 = true
debugPrint("getSubscriptionStatus user subscription is active.")
} else {
purchaseStatus1 = false
debugPrint("getSubscriptionStatus user subscription is expiring.")
}
case .inBillingRetryPeriod:
debugPrint("getSubscriptionStatus user subscription is in billing retry period.")
purchaseStatus1 = false
case .inGracePeriod:
debugPrint("getSubscriptionStatus user subscription is in grace period.")
purchaseStatus1 = false
case .expired:
debugPrint("getSubscriptionStatus user subscription is expired.")
purchaseStatus1 = false
case .revoked:
debugPrint("getSubscriptionStatus user subscription was revoked.")
purchaseStatus1 = false
default:
fatalError("getSubscriptionStatus WARNING STATE NOT CONSIDERED.")
}
}
} catch {
// do nothing
}
guard let subscription2 = storeProducts.last?.subscription else {
// Not a subscription
return
}
do {
let statuses = try await subscription2.status
for status in statuses {
let info = try checkVerified(status.renewalInfo)
switch status.state {
case .subscribed:
if info.willAutoRenew {
purchaseStatus2 = true
debugPrint("getSubscriptionStatus user subscription is active.")
} else {
purchaseStatus2 = false
debugPrint("getSubscriptionStatus user subscription is expiring.")
}
case .inBillingRetryPeriod:
debugPrint("getSubscriptionStatus user subscription is in billing retry period.")
purchaseStatus2 = false
case .inGracePeriod:
debugPrint("getSubscriptionStatus user subscription is in grace period.")
purchaseStatus2 = false
case .expired:
debugPrint("getSubscriptionStatus user subscription is expired.")
purchaseStatus2 = false
case .revoked:
debugPrint("getSubscriptionStatus user subscription was revoked.")
purchaseStatus2 = false
default:
fatalError("getSubscriptionStatus WARNING STATE NOT CONSIDERED.")
}
}
} catch {
// do nothing
}
if purchaseStatus1 == true || purchaseStatus2 == true {
purchaseStatus = true
} else if purchaseStatus1 == false && purchaseStatus2 == false {
purchaseStatus = false
}
return
}
Topic:
App & System Services
SubTopic:
StoreKit
Hi,
From App analytics, we found that our app crashed from time to time on users' devices despite that we have tested it thoroughly on our devices. We are doubt that it's the reason why we can't retain them. But how can we get the crash reports for the app installed on user devices? We have no users' emails and can't ask them directly.
Hi,
I have developed a calendar app with swiftData. I have set it to sync iCloud. When testing it, it seems that everything is fine. But after it's released, today, I uninstalled it and reinstalled it again. And I found that iCloud hasn't sync with local swiftData for six days. I have lost six days agenda and relevant information. I have checked the document, and it's said that there is no method to force to sync with iCloud. How to solve the issue? I think that the users can't forgive that it hasn't synced for six days.
Best Wishes,
Topic:
App & System Services
SubTopic:
iCloud & Data
We have set monthly/yearly subscriptions in our app and they have been approved. The users can get access to the limited functions of the app for free. For example, they can create limited number of tasks/events in the App. But if they want to create more tasks/events in the App, they need to subscribe the app(monthly/yearly).
But we don't know why the app is shown as an one-time purchase app in App store. The users need to pay the one-time purchase fee at first to download the app. If they haven't tried the app, they wont' pay for it. How to fix it? Look forward to the reply about it ASAP.
The rejection reason is more and more ridiculous. I design an app that will save some data from the users. And the app requires users to register for saving the data. The rejection reason from Apple review team is that you can't let users to register. They should save their data without the step. I want to ask, why does iPhone/iPad require users to register when they launch their devices for the first time? And I found Apple review team become very rude and not patient this year. I have answered their same questions for ten times and have written detailed guidelines about them. But guess what, the reviewers from Apple never read the guidelines. Their plan seem to be like, never let any new app to launch in App store although the incomes from these app are the important profit source for Apple. I don't know who is leading the team now. But I indeed know that the ridiculous working style will ruin Apple business in the end.
Topic:
App Store Distribution & Marketing
SubTopic:
App Review
I want to apply a new sandbox account. I click Users and Access, and then click sandbox, but the sandbox page is totally empty. It's weird. I have set up an account before. But after I delete it and click the sandbox, the sandbox page is totally empty now. Why?
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Hi,
I have designed an app which needs to reschedule notifications according to the user's calendar at midnight. The function has been implemented successfully via backgroundtask. But since the app has enabled iCloud sync, some users will edit their calendar on their iPad and expect that the notifications will be sent promptly to them on iPhone without launching the app on their iPhone. But the problem is that if they haven't launched the app on their iPhone, iCloud sync won't happen. The notifications on their iPhone haven't been updated and will be sent wrongly. How can I design some codes to let iCloud sync across the devices without launching the app at midnight and then reschedule notifications?
Hi, Everyone,
I have submitted an app for review but after more than one week, the status is still waiting for review. The review website said that 90% of review will be completed in 24 hours. I have submitted expidite request but no response. What should I do for the next step to accelate the review process?
Hi, Everyone
I set up a class for sharing photos to facebook. The codes of the class are as following. But when I call the function "shareToFacebook", there is no dialog to show. What's the issue in these codes? I am using iOS 17.0, Xcode The guide from Facebook hasn't updated.
import SwiftUI
import FBSDKShareKit
import FacebookShare
@Observable
class ShareFacebook {
var content = SharePhotoContent()
var images : [UIImage] = []
var photos : [SharePhoto] = []
func shareToFacebook() {
for image in images {
let photo = SharePhoto(
image: image,
isUserGenerated: true
)
photos.append(photo)
}
content.photos = photos
let dialog = ShareDialog(
viewController: UIApplication.shared.currentUIWindow()?.rootViewController,
content: content,
delegate: nil )
dialog.show()
}
}
//button for sharing
//Sharing to Facebook
Button {
for image in photos {
let image = UIImage(data: image.imageData)
sharedPhotos.append(image ?? userViewModel.render(image: Image("photoForNil"))! )
}
shareToFacebook.images = sharedPhotos
shareToFacebook.shareToFacebook()
}label: {
Image("share")
.resizable()
.frame(width:18, height: 18)
.padding(.trailing,30)
}
I have a textfield to allow users to input their numbers. It works well until I upgrade to IOS 17.0 yesterday. After upgrading to IOS 17.0, the number input by user can't be cleared when user wants to input another number. More specifically, the last figure can't be deleted.For example, the user originally input 50, and he/she wants to delete it to input another figure. But 5 can't be deleted and only 0 is deleted. So user can't input a new number in the textfield. Is a bug from IOS17.0? How can I fix it. My code about the textfield is as following:
TextField("Focus Time", value: $userViewModel.focusTime, format: .number) .frame(width: 220, height: nil) .keyboardType(.numberPad) .textFieldStyle(.roundedBorder) .font(Font.system(size: 25, design: .default)) .multilineTextAlignment(TextAlignment.center) .focused($textIsFocused1) .onTapGesture { textIsFocused1.toggle() }