Initialize Setapp Framework
Once you've added the public key, you should tell our Setapp Framework its location. By default, we assume that the public key file is named setappPublicKey.pem
and located in the app's main bundle.
Start
The start(with:)
method of the SetappManager
class is responsible for these initialization operations:
- Providing configuration for the Setapp Framework so that it starts for your app;
- Starting reporting the app usage once it is successfully activated for a Setapp user.
If you have the UIApplicationDelegate
method in your app, add the following code to the application(_:, didFinishLaunchingWithOptions:)
function:
import Setapp
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
)
-> Bool
{
SetappManager.shared.start(with: .default)
return true
}
}
If you have UIWindowSceneDelegate
in your app, add the code below to the scene(_:, willConnectTo:, options:)
function:
import Setapp
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
)
{
SetappManager.shared.start(with: .default)
}
}
Provide custom configuration
You’ll need to provide a custom configuration for the SetappManager
class in the following cases:
- You’re not using the main app bundle to store the public key.
- You have renamed the public key file in your project.
Providing configuration must take place while initializing the Setapp Framework.
let configuration = SetappConfiguration(
publicKeyBundle: .main,
publicKeyFilename: "setappPublicKey.pem"
)
SetappManager.shared.start(with: configuration)
Tip
If you have integrated Setapp Framework before, please adjust initialization Setapp Framework code: add public key of your Setapp Mobile app to
SetappManager.shared.start()
andSetappManager.shared.start(with:setappMobileConfiguration:)
as a second parameter.
Updated 5 months ago