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
WordPressCom-Stats-iOS requires iOS 7.0 or higher and ARC. It depends on the following Apple frameworks:
and the following CocoaPods:
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.
Developer blog & Handbook
To report an issue (for the stats component only)
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.