🚨 Deprecation Notice: 🚨 As of 8-May-2017 this project has been deprecated and will no longer be updated. The code is here for historical purposes only. The WordPressCom-Stats-iOS project was merged into the main WordPress-iOS project as a dynamic framework. Please report any stats-related issues to the main WordPress-iOS repo.
WordPressCom-Stats-iOS is a reusable component used in the WordPress iOS app to show stats for sites hosted on WordPress.com. You can use the UIViewController subclass inside of your own applications or use one of the services to pull stats for your own use.
You can install the stats component in your app via CocoaPods:
platform :ios, '10.0'
pod 'WordPressCom-Stats-iOS'
Or, you can just try out the demo by using the CocoaPods try command:
pod try WordPressCom-Stats-iOS
WordPressCom-Stats-iOS requires iOS 7.0 or higher and ARC. It depends on the following Apple frameworks:
- Foundation.framework
- UIKit.framework
- CoreGraphics.framework
and the following CocoaPods:
- AFNetworking
- CocoaLumberjack
- NSObject+SafeExpectations
- WordPress-iOS-Shared
- WordPressCom-Analytics-iOS
See the podspec for more details.
There are three things that you need to do in order to use WordPressCom-Stats-iOS in your app.
-
Create a UIViewController subclass that extends
WPStatsViewController
. (Optionally you may choose to use composition and have your UIViewController contain an instance of WPStatsViewController and add as a subview. Take a look at the demo project for an example.)#import <UIKit/UIKit.h> #import <WordPressCom-Stats-iOS/WPStatsViewController.h> @interface WPViewController : WPStatsViewController <WPStatsViewControllerDelegate> @end
-
Obtain an OAuth2 token from WordPress.com. Currently the authentication mechanism to WordPress.com is not part of a reusable library. You will need to obtain this manually by following (these directions)[https://developer.wordpress.com/docs/oauth2/]. The easiest way to snag the OAuth2 token is by setting a breakpoint in the WordPress-iOS application after generating a token.
-
Obtain the site/blog ID for the site you wish to view stats for.
-
Pass the site ID and OAuth2 token to either the init method or set as parameters before displaying the view from the controller.
For more details, you can review the StatsDemo project included in this repo.
Blog: http://make.wordpress.org/mobile
Handbook: http://make.wordpress.org/mobile/handbook/
https://github.com/wordpress-mobile/WordPress-iOS/wiki/WordPress-for-iOS-Style-Guide
https://github.com/wordpress-mobile/WordPressCom-Stats-iOS/issues?state=open
GitHub: https://github.com/wordpress-mobile/WordPressCom-Stats-iOS/
http://make.wordpress.org/mobile/handbook/pathways/ios/how-to-contribute/
- Replace networking stack with WordPressComApi shared pod
WordPressCom-Stats-iOS is available under the MIT license. See the LICENSE file for more info.