aptabase / aptabase-swift

Swift SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps
https://aptabase.com
MIT License
23 stars 8 forks source link

Example for UIKit #2

Open bircni opened 1 year ago

bircni commented 1 year ago

I suggest adding an example how to use it in UIKit - I did it like this: In the main class I initialize aptabase and it just works:

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        Aptabase.shared.initialize(appKey: "")
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
         Aptabase.shared.initialize(appKey: "")
    }
goenning commented 1 year ago

That's a good suggestion, I'm not too familiar with UIKit, so I need to experiment a bit.

In your example you have called initialize twice. Is that really needed? Have you tried initialising it on AppDelegate?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        Aptabase.shared.initialize(appKey: "")
        return true
    }
bircni commented 1 year ago

no but this should work i guess

bircni commented 1 year ago

it depends on how init is called...