I have a MacOS application that has a non-consumable in-app purchase that unlocks an enhanced version of the app (in other words, it's a one-time upgrade purchased inside of the app). The transaction is handled using StoreKit 2 and the app is distributed on the MacOS App Store.
I would like to add an affiliate-like program where certain people can promote my application and receive a percentage of the earnings from users that buy the in-app purchase as a result of their promotion. In order to correctly distribute earnings, I need some way to track that a purchase from a user is linked to a certain affiliate.
Research led me to offer codes but I quickly realised that these are only valid for subscriptions (which my purchase is not), and, besides, it seems they are not supported on MacOS. Another constraint that I have is that my application should not make any external network requests (apart from those to Apple servers, like StoreKit), so I cannot use something like Firebase for a custom offer implementation.
I'm not sure what the best way to achieve this is. One way I thought of is to create one non-consumable in-app purchase/product for each affiliate and use a deep link to associate a user with that product. Then, I'll know which affiliate each user comes from based on the product that was used during the purchase. The only problem with this is that products need to be aded at compile-time so each new affiliate I add would require me to publish a new app version.
I'm wondering whether there's a better way to do this?
Post
Replies
Boosts
Views
Activity
I have a MacOS app that is distributed through the App Store. I've created a campaign in order to track where installs come from.
The campaign has a generated campaign token and provider token which can be used for tracking.
Is there any way to retrieve the campaign token and provider token (which was used to install the app) inside the app?
Hello,
I'm currently developing a SwiftUI app for macOS that includes both free and premium features. One of the features is the maximum amount of items that can be stored in the app: the free version allows users to store up to 10 items, whereas premium users can store up to 1000.
The issue I'm facing is with securing the premium feature. I'm using UserDefaults to store the value of the feature, with a key named maxStorageSize. The user can configure this using a dropdown (there are also other options between 10 and 1000). For non-premium users, this dropdown is disabled and set to a default of 10. For premium users, the dropdown is enabled and thus the user can change the setting to a higher value.
However, I've realised that this limitation can be bypassed by using the defaults CLI tool to change the value of maxStorageSize underneath the application's knowledge, effectively circumventing the premium requirement.
My current workaround is:
check the user defaults on launch and if the user is non-premium and any of the premium features have been changed: reset them.
continuously monitor for updates on the defaults and if the user is non-premium and a premium feature value has been changed: reset it.
This seems to work but feels a little hacky. I'm wondering what mechanisms you've come up with to solve this.
I have a MacOS app that has some print statements in code.
I'm running the MacOS app as a pre-compiled binary (not from Xcode, i.e. from the store). Are print logs stored anywhere? Is there any way to see them?
I'm trying to achieve the look seen below in Xcode's about window, where there is no border between the title bar of the window and the content view, but I can't seem to get rid of the border between the title bar and the content view.
This is my code:
struct MyView: View {
var body: some View {
HStack {
Text("Hello world")
}
.frame(width: 200, height: 200)
}
}
...
myWindow = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 200, height: 200),
styleMask: [.closable, .titled],
backing: .buffered, defer: false)
myWindow.contentView = NSHostingView(rootView: MyView())
Which results in:
Is this a SwiftUI native control for MacOS?
With the following code:
@Model
final class Item {
var data: [Data]
init(data: [Data]) {
self.data = data
}
}
@Model
final class Data {
var contents: String
init(contents: String) {
self.contents = contents
}
}
..
let data = Data(contents: "yo")
let newItem = Item(timestamp: Date(), data: [data])
print(newItem.data) // <-- exception thrown here
I get an exception on the print line when accessing the .data field:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1f379a29c)
Note that if I first save newItem to the context the exception is not thrown, i.e.:
let data = Data(contents: "yo")
let newItem = Item(timestamp: Date(), data: [data])
modelContext.insert(newItem)
print(newItem.data) // <-- no exception
Unfortunately the exception is cryptic so I can't tell what's wrong.
Xcode version 15.0 beta 8 (15A5229m)
macOS Sonoma beta 14.0 (23A5337a)
I have a MacOS menu bar application and I'm trying to display an NSPopover in the center of the screen. This is the code I've come up with so far:
class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
private var statusItem: NSStatusItem!
private var popover: NSPopover!
@MainActor func applicationDidFinishLaunching(_ notification: Notification) {
// ... init of statusItem hidden
self.popover = NSPopover()
self.popover.contentSize = NSSize(width: 300, height: 300)
self.popover.behavior = .transient
self.popover.contentViewController = NSHostingController(rootView: ContentView())
}
@objc func togglePopover() {
if let button = statusItem.button {
if popover.isShown {
self.popover.performClose(nil)
} else {
if let screen = NSScreen.main {
let screenFrame = screen.visibleFrame
let x = screenFrame.origin.x + (screenFrame.width - self.popover.contentSize.width) / 2
let y = screenFrame.origin.y + (screenFrame.height - self.popover.contentSize.height) / 2
let centerPoint = NSPoint(x: x, y: y)
popover.show(relativeTo: NSRect(origin: centerPoint, size: CGSize.zero), of: screenFrame, preferredEdge: NSRectEdge.minX)
}
}
}
}
}
Unfortunately the code above does not compile because the of parameter of popover.show expects an NSView, whereas screenFrame is an NSRect. I've tried creating a view out of the rect but this leads to a run-time error that the view is not contained within a window.
Any thoughts?
I have both Xcode 15.0 beta 4 and beta 5 installed.
How do I uninstall beta 4? It does not exist in the Applications folder.