mixpanel-swift/docs/docsets/Mixpanel.docset/Contents/Resources/Documents/index.html
2020-01-06 16:38:33 -08:00

307 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Mixpanel Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
</head>
<body>
<a title="Mixpanel Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html">Mixpanel 2.6.8 Docs</a> (91% documented)</p>
<p class="header-right"><a href="https://github.com/mixpanel/mixpanel-swift"><img src="img/gh.png"/>View on GitHub</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html">Mixpanel Reference</a>
<img id="carat" src="img/carat.png" />
Mixpanel Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Classes/Group.html">Group</a>
</li>
<li class="nav-group-task">
<a href="Classes/Mixpanel.html">Mixpanel</a>
</li>
<li class="nav-group-task">
<a href="Classes/MixpanelInstance.html">MixpanelInstance</a>
</li>
<li class="nav-group-task">
<a href="Classes/People.html">People</a>
</li>
<li class="nav-group-task">
<a href="Classes.html#/s:8Mixpanel10TweakStoreC">TweakStore</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Enums/TweakViewDataType.html">TweakViewDataType</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Extensions/Array.html">Array</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Bool.html">Bool</a>
</li>
<li class="nav-group-task">
<a href="Extensions/CGFloat.html">CGFloat</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Date.html">Date</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Dictionary.html">Dictionary</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Double.html">Double</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Float.html">Float</a>
</li>
<li class="nav-group-task">
<a href="Extensions/Int.html">Int</a>
</li>
<li class="nav-group-task">
<a href="Extensions/NSNull.html">NSNull</a>
</li>
<li class="nav-group-task">
<a href="Extensions/String.html">String</a>
</li>
<li class="nav-group-task">
<a href="Extensions/UIColor.html">UIColor</a>
</li>
<li class="nav-group-task">
<a href="Extensions/UInt.html">UInt</a>
</li>
<li class="nav-group-task">
<a href="Extensions/URL.html">URL</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Functions.html">Functions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Functions.html#/s:8Mixpanel2eeoiySbAA5TweakVyxG_AEtAA13TweakableTypeRzlF">==(_:_:)</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/s:8Mixpanel2eeoiySbAA8AnyTweakV_ADtF">==(_:_:)</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Protocols/MixpanelDelegate.html">MixpanelDelegate</a>
</li>
<li class="nav-group-task">
<a href="Protocols/MixpanelType.html">MixpanelType</a>
</li>
<li class="nav-group-task">
<a href="Protocols/TweakClusterType.html">TweakClusterType</a>
</li>
<li class="nav-group-task">
<a href="Protocols/TweakLibraryType.html">TweakLibraryType</a>
</li>
<li class="nav-group-task">
<a href="Protocols/TweakableType.html">TweakableType</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Structs/AnyTweak.html">AnyTweak</a>
</li>
<li class="nav-group-task">
<a href="Structs/MixpanelTweaks.html">MixpanelTweaks</a>
</li>
<li class="nav-group-task">
<a href="Structs/Tweak.html">Tweak</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Typealiases.html#/s:8Mixpanel10Propertiesa">Properties</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<p align="center">
<img src="https://github.com/mixpanel/mixpanel-swift/blob/assets/mixpanelswift.png?raw=true" alt="Mixpanel Swift Library" height="200"/>
</p>
<p><a href="https://travis-ci.org/mixpanel/mixpanel-swift"><img src="https://travis-ci.org/mixpanel/mixpanel-swift.svg" alt="Build Status"></a>
<a href="http://isitmaintained.com/project/mixpanel/mixpanel-swift" title="Average time to resolve an issue"><img src="http://isitmaintained.com/badge/resolution/mixpanel/mixpanel-swift.svg" alt="Average time to resolve an issue"></a>
<a href="http://isitmaintained.com/project/mixpanel/mixpanel-swift" title="Percentage of issues still open"><img src="http://isitmaintained.com/badge/open/mixpanel/mixpanel-swift.svg" alt="Percentage of issues still open"></a>
<a href="https://mixpanel.com"><img src="http://img.shields.io/cocoapods/v/Mixpanel-swift.svg" alt="CocoaPods Compatible"></a>
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg" alt="Carthage compatible"></a>
<a href="https://mixpanel.com"><img src="http://img.shields.io/cocoapods/l/Mixpanel-swift.svg" alt="Apache License"></a>
<a href="https://mixpanel.github.io/mixpanel-swift"><img src="https://mixpanel.github.io/mixpanel-swift/badge.svg" alt="Documentation"></a></p>
<h1 id='table-of-contents' class='heading'>Table of Contents</h1>
<!-- MarkdownTOC -->
<ul>
<li><a href="#introduction">Introduction</a>
<ul>
<li><a href="#current-supported-features">Current supported features</a></li>
</ul></li>
<li><a href="#installation">Installation</a>
<ul>
<li><a href="#cocoapods">CocoaPods</a></li>
<li><a href="#carthage">Carthage</a></li>
<li><a href="#manual-installation">Manual Installation</a></li>
</ul></li>
<li><a href="#initializing-and-usage">Initializing and Usage</a>
<ul>
<li><a href="#integrate">Integrate</a></li>
<li><a href="#start-tracking">Start tracking</a></li>
</ul></li>
</ul>
<!-- /MarkdownTOC -->
<p><a name="introduction"></a></p>
<h1 id='introduction' class='heading'>Introduction</h1>
<p>Welcome to the official Mixpanel Swift Library</p>
<p>The Mixpanel Swift library for iOS is an open source project, and we&rsquo;d love to see your contributions!
We&rsquo;d also love for you to come and work with us! Check out <strong><a href="https://mixpanel.com/jobs/#openings">Jobs</a></strong> for details.</p>
<p>If you are using Objective-C, we recommend using our <strong><a href="https://github.com/mixpanel/mixpanel-iphone">Objective-C Library</a></strong>.</p>
<p><a name="current-supported-features"></a></p>
<h2 id='current-supported-features' class='heading'>Current supported features</h2>
<p><strong>Our master branch and our releases are now on Swift 5.</strong></p>
<p><strong>If you wish to use our Swift 4.2 implementation, please point to the v2.6.1 release. For Swift 4/4.1 implementation, please point to the v2.4.5 release. For Swift 3 implementation, please point to the v2.2.3 release. For Swift 2.3 implementation, please point to the v1.0.1 release.</strong></p>
<p>Our Swift library fully supports all of the Mixpanel features, and has full parity with the <a href="https://github.com/mixpanel/mixpanel-iphone">Objective-C Library</a>.</p>
<p><a name="installation"></a></p>
<h1 id='installation' class='heading'>Installation</h1>
<p><a name="cocoapods"></a></p>
<h2 id='cocoapods' class='heading'>CocoaPods</h2>
<p><strong>Our current release only supports CocoaPods version 1.4.0+</strong></p>
<p>Mixpanel supports <code>CocoaPods</code> for easy installation.
To Install, see our <strong><a href="https://mixpanel.com/help/reference/swift">swift integration guide »</a></strong></p>
<p>For iOS, tvOS, macOS, and App Extension integrations:</p>
<p><code>pod &#39;Mixpanel-swift&#39;</code></p>
<p><a name="carthage"></a></p>
<h2 id='carthage' class='heading'>Carthage</h2>
<p>Mixpanel also supports <code>Carthage</code> to package your dependencies as a framework. Include the following dependency in your Cartfile:</p>
<p><code>github &quot;mixpanel/mixpanel-swift&quot;</code></p>
<p>Check out the <strong><a href="https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos">Carthage docs »</a></strong> for more info. </p>
<p><a name="manual-installation"></a></p>
<h2 id='manual-installation' class='heading'>Manual Installation</h2>
<p>To help users stay up to date with the latests version of our Swift SDK, we always recommend integrating our SDK via CocoaPods, which simplifies version updates and dependency management. However, there are cases where users can&rsquo;t use CocoaPods. Not to worry, just follow these manual installation steps and you&rsquo;ll be all set.</p>
<h3 id='step-1-add-as-a-submodule' class='heading'>Step 1: Add as a Submodule</h3>
<p>Add Mixpanel as a submodule to your local git repo like so:</p>
<pre class="highlight plaintext"><code>git submodule add git@github.com:mixpanel/mixpanel-swift.git
</code></pre>
<p>Now the Mixpanel project and its files should be in your project folder! </p>
<h3 id='step-2-drag-mixpanel-to-your-project' class='heading'>Step 2: Drag Mixpanel to your project</h3>
<p>Drag the Mixpanel.xcodeproj inside your sample project under the main sample project file:</p>
<p><img src="http://images.mxpnl.com/docs/2016-07-19%2023:34:02.724663-Screen%20Shot%202016-07-19%20at%204.33.34%20PM.png" alt="alt text"></p>
<h3 id='step-3-embed-the-framework' class='heading'>Step 3: Embed the framework</h3>
<p>Select your app .xcodeproj file. Under &ldquo;General&rdquo;, add the Mixpanel framework as an embedded binary:</p>
<p><img src="http://images.mxpnl.com/docs/2016-07-19%2023:31:29.237158-add_framework.png" alt="alt text"></p>
<p><a name="initializing-and-usage"></a></p>
<h1 id='initializing-and-usage' class='heading'>Initializing and Usage</h1>
<p><a name="integrate"></a></p>
<h2 id='integrate' class='heading'>Integrate</h2>
<p>Import Mixpanel into AppDelegate.swift, and initialize Mixpanel within <code>application:didFinishLaunchingWithOptions:</code>
<img src="http://images.mxpnl.com/docs/2016-07-19%2023:27:03.724972-Screen%20Shot%202016-07-18%20at%207.16.51%20PM.png" alt="alt text"></p>
<pre class="highlight swift"><code><span class="kd">func</span> <span class="nf">application</span><span class="p">(</span><span class="n">_</span> <span class="nv">application</span><span class="p">:</span> <span class="kt">UIApplication</span><span class="p">,</span>
<span class="n">didFinishLaunchingWithOptions</span> <span class="nv">launchOptions</span><span class="p">:</span> <span class="p">[</span><span class="kt">NSObject</span><span class="p">:</span> <span class="kt">AnyObject</span><span class="p">]?)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span> <span class="p">{</span>
<span class="kt">Mixpanel</span><span class="o">.</span><span class="nf">initialize</span><span class="p">(</span><span class="nv">token</span><span class="p">:</span> <span class="s">"MIXPANEL_TOKEN"</span><span class="p">)</span>
<span class="p">}</span>
</code></pre>
<p>You initialize your Mixpanel instance with the token provided to you on mixpanel.com.</p>
<p><a name="start-tracking"></a></p>
<h2 id='start-tracking' class='heading'>Start tracking</h2>
<p>After installing the library into your iOS app, Mixpanel will <a href="https://mixpanel.com/help/questions/articles/which-common-mobile-events-can-mixpanel-collect-on-my-behalf-automatically" target="_blank">automatically collect common mobile events</a>. You can enable/ disable automatic collection through your <a href="https://mixpanel.com/help/questions/articles/how-do-i-enable-common-mobile-events-if-i-have-already-implemented-mixpanel" target="_blank">project settings</a>.</p>
<p>To interact with the instance and track additional events, you can either use the mixpanel instance given when initializing:</p>
<pre class="highlight swift"><code><span class="n">mixpanel</span><span class="o">.</span><span class="nf">track</span><span class="p">(</span><span class="nv">event</span><span class="p">:</span> <span class="s">"Tracked Event!"</span><span class="p">)</span>
</code></pre>
<p>or you can directly fetch the instance and use it from the Mixpanel object:</p>
<pre class="highlight swift"><code><span class="kt">Mixpanel</span><span class="o">.</span><span class="nf">mainInstance</span><span class="p">()</span><span class="o">.</span><span class="nf">track</span><span class="p">(</span><span class="nv">event</span><span class="p">:</span> <span class="s">"Tracked Event!"</span><span class="p">)</span>
</code></pre>
<p>You&rsquo;re done! You&rsquo;ve successfully integrated the Mixpanel Swift SDK into your app. To stay up to speed on important SDK releases and updates, star or watch our repository on <a href="https://github.com/mixpanel/mixpanel-swift">Github</a>.</p>
<p>Have any questions? Reach out to <a href="mailto:support@mixpanel.com">support@mixpanel.com</a> to speak to someone smart, quickly.</p>
</section>
</section>
<section id="footer">
<p>&copy; 2020 <a class="link" href="http://mixpanel.com" target="_blank" rel="external">Mixpanel</a>. All rights reserved. (Last updated: 2020-01-06)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>