mixpanel-iphone

适用于Mixpanel Analytics的iPhone跟踪库。(iPhone tracking library for Mixpanel Analytics)

Github星跟蹤圖

Build Status
Average time to resolve an issue
Percentage of issues still open
CocoaPods Version
Carthage compatible
Apache License

Table of Contents

Introduction

The Mixpanel library for iOS is an open source project, and we'd love to see your contributions! We'd also love for you to come and work with us! Check out https://mixpanel.com/jobs/#openings for details.

If you are using Swift, we recommend our Swift Library.

Installation

CocoaPods

Mixpanel supports CocoaPods for easy installation.
To Install, see our full documentation »

iOS, tvOS, watchOS, macOS:

pod 'Mixpanel'

Carthage

Mixpanel also supports Carthage to package your dependencies as a framework.
Check out the Carthage docs » for more info.

To integrate Mixpanel into your Xcode project using Carthage, specify it in your Cartfile:

github "mixpanel/mixpanel-iphone"

Run carthage update to build the framework and drag the built Mixpanel.framework into your Xcode project.

Manual Installation

To help users stay up to date with the latests version of our iOS SDK, we always recommend integrating our SDK via CocoaPods, which simplifies version updates and dependency management. However, there are cases where users can't use CocoaPods. Not to worry, just follow these manual installation steps and you'll be all set.

Step 1: Add as a submodule

Add Mixpanel as a submodule to your local git repo like so:

git submodule add git@github.com:mixpanel/mixpanel-iphone.git

Now the Mixpanel project and its files should be in your project folder!

Step 2: Add the SDK to your app!

Drag and drop Mixpanel.xcodeproj from the mixpanel-iphone folder into your Xcode Project Workspace:

alt text

Step 3: Embed the Mixpanel framework

Select your app .xcodeproj file. Under "General", add the Mixpanel framework as an embedded binary. Once added, please make sure Mixpanel.framework shows under both "Linked Frameworks and Libaries" and "Embedded Binaries".

Integrate

Import <Mixpanel/Mixpanel.h> into AppDelegate.m, and initialize Mixpanel within application:didFinishLaunchingWithOptions:

#import "AppDelegate.h"
#import <Mixpanel/Mixpanel.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Mixpanel sharedInstanceWithToken:MIXPANEL_TOKEN];
}

You initialize your Mixpanel instance with the token provided to you on mixpanel.com.

Start tracking

After installing the library into your iOS app, Mixpanel will automatically collect common mobile events. You can enable/ disable automatic collection through your project settings.

Tracking additional events is as easy as adding track: or track:properties: anywhere after initializing Mixpanel.

[[Mixpanel sharedInstance] track:@"Event name"];
[[Mixpanel sharedInstance] track:@"Event name" properties:@{@"Prop name": @"Prop value"}];

You're done! You've successfully integrated the Mixpanel SDK into your app. To stay up to speed on important SDK releases and updates watch our iPhone repository on Github.

Have any questions? Reach out to support@mixpanel.com to speak to someone smart, quickly.

Using Mixpanel Push Notifications

First enable Mixpanel push notifications in your app. Then for Rich Push Notifications, you'll need to integrate your application with the MixpanelNotificationServiceExtension.

Integrating the MixpanelNotificationServiceExtension

The Mixpanel SDK comes with a custom Notification Service Extension used to render rich media, custom action buttons, and track when push notifications are received. In order to enable these features, you will need to integrate it into your application.

1. Create a new Notification Service Extension Target

2. Add Mixpanel as a dependency

Add the following to the end of your Podfile:

target 'NotificationService' do
  use_frameworks!
  
  pod 'Mixpanel'
end

Then run pod install

3. Extend your NotificationService from MixpanelNotificationServiceExtension

Replace the contents of your NotificationService.h file with the following:

@import Mixpanel;

@interface NotificationService : MPNotificationServiceExtension

@end

Replace the contents of your NotificationService.m file with the following:

#import "NotificationService.h"

@implementation NotificationService

@end

4. Run the app and send a test push notification from Mixpanel that includes an image or buttons

That's it! Your app should now be able to receive rich push notifications from Mixpanel.

主要指標

概覽
名稱與所有者mixpanel/mixpanel-iphone
主編程語言Objective-C
編程語言Objective-C (語言數: 6)
平台iOS
許可證Apache License 2.0
所有者活动
創建於2010-07-14 17:48:47
推送於2025-02-26 22:24:14
最后一次提交2025-02-26 22:24:13
發布數159
最新版本名稱v5.0.8 (發布於 2025-02-26 14:21:59)
第一版名稱v1.0.0 (發布於 2012-11-14 20:00:57)
用户参与
星數1k
關注者數120
派生數568
提交數2.5k
已啟用問題?
問題數497
打開的問題數11
拉請求數390
打開的拉請求數0
關閉的拉請求數142
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?