applicationInstall
The applicationInstall() method records the installation of the app. The event is sent the first time the app is launched, once per installation. If a user installs your app but doesn't run it, the event is not sent.
Syntax
PiwikTracker.sharedInstance()?.applicationInstall()[[PiwikTracker sharedInstance] applicationInstall];Examples
Call applicationInstall() from App.init() immediately after configuring the tracker:
@main
struct MyApp: App {
init() {
PiwikTracker.sharedInstance(
siteID: "site-id",
baseURL: URL(string: "https://example.piwik.pro")!
)
PiwikTracker.sharedInstance()?.applicationInstall()
}
var body: some Scene {
WindowGroup { ContentView() }
}
}Or from application(_:didFinishLaunchingWithOptions:) when you use an AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
PiwikTracker.sharedInstance(siteID: "site-id", baseURL: URL(string: "https://example.piwik.pro")!)
PiwikTracker.sharedInstance()?.applicationInstall()
return true
}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[PiwikTracker sharedInstanceWithSiteID:@"site-id" baseURL:[NSURL URLWithString:@"https://example.piwik.pro"]];
[[PiwikTracker sharedInstance] applicationInstall];
return YES;
}Notes
- Call
applicationInstall()immediately after configuring the tracker, because this event is only sent to the server once per app installation. - Further calls on the same install do not enqueue another install event. The boolean return value indicates whether a new event was queued.
- Prefer this over the deprecated
sendApplicationDownload(), which fires at most once per app version;applicationInstall()fires at most once per device installation.
Related methods
applicationUpdate()sendApplicationDownload()(deprecated)
Updated 15 days ago