WordPressCom-Stats-iOS
Introduction
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.
How to get started
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
Requirements
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.
Usage
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.
Other Resources
Developer blog & Handbook
Blog: http://make.wordpress.org/mobile
Handbook: http://make.wordpress.org/mobile/handbook/
Style guide
https://github.com/wordpress-mobile/WordPress-iOS/wiki/WordPress-for-iOS-Style-Guide
To report an issue (for the stats component only)
https://github.com/wordpress-mobile/WordPressCom-Stats-iOS/issues?state=open
Source Code
GitHub: https://github.com/wordpress-mobile/WordPressCom-Stats-iOS/
How to Contribute
http://make.wordpress.org/mobile/handbook/pathways/ios/how-to-contribute/
Future Enhancements
- Replace networking stack with WordPressComApi shared pod
License
WordPressCom-Stats-iOS is available under the MIT license. See the LICENSE file for more info.