My app has been in the app store for a while now. I now want to add an app clip which has a button that sends the users to download the full app from the app store (Using SKOverlay
). In addition, I want the app clip to pass parameters to the full app (this step is crucial).
for example, the user's name will be passed to the full app and presented in the main activity. This is done by putting this info in the shared user defaults
in the app clip, and extracting this info from the shared user defaults
in the full app.
I created the app clip with these features and now want to test the transition from the app clip to the full app.
I tried 3 different approaches, but none of them enabled me to simulate the full app-clip-to-full-app experience:
_XCAppClipURL
environment variable. The SKOverlay popped up but it doesn't actually enable me to open the app store.shared user defaults
.Is there a way for me to test this transition without releasing the newest version to the app store?
EDIT: I'm using the UserDefaults with an app group. I defined an app group with the same name in the 'signing and capabilities' section of both the full app and the app clip. And added the following code:
In the app clip's scene delegate:
let username = "Oded"
guard let sharedUserDefaults = UserDefaults(suiteName: "group.fruitapp.appClipToFullApp") else {
return true
}
if sharedUserDefaults.string(forKey: "username") == nil {
sharedUserDefaults.set(username, forKey: "username")
}
return true
In the full app's app delegate:
guard let sharedUserDefaults = UserDefaults(suiteName: "group.fruitapp.appClipToFullApp"),
let username = sharedUserDefaults.url(forKey: "username")
else {
print("Could not find the App Group or the usename from the app clip")
return
}
print("username is \(username)")
//Do more stuff
I also struggled with testing this transition and thought it was not possible at one point. It's not only possible, but actually pretty important to test so that the upgrade experience is smooth.
Some points:
_XCAppClipURL
), and then simulate the upgrade by building your full app to the same device.UserDefaults
API properly. NOTE: The setup part is tricky, if you don't see the data you expect after you build your full app, then it's not set up correctly.Some things to check:
Those two things might be obvious but I got them wrong.