Studyplus iOS SDK
- iOS 7.0 or above
- Xcode command line tools
- ARC
- Studyplus iOS App 3.10.0 or adove
- CocoaPods (Optional, but recommended)
# Edit your podfile
platform :ios, '7.0'
pod 'StudyplusSDK'
and run
pod install
- Get StudyplusSDK.
git clone https://github.com/studyplus/Studyplus-iOS-SDK
or download zip from this page.
- Copy
build/Release/deliverables/StudyplusSDK
to your project. - Install AFNetworking and UICKeyChainStore too.
- Add required frameworks(i.e.
Security.framework, SystemConfiguration.framework, MobileCoreServices, CoreGraphics
etc). See AFNetworking and UICKeyChainStore.
- Get StudyplusSDK
git clone https://github.com/studyplus/Studyplus-iOS-SDK
or download zip from this page.
- Copy Studyplus-iOS-SDK/StudyplusSDK directory to your project.
- Install AFNetworking and UICKeyChainStore too.
set "studyplus-{your consumer key}" to URL Types.
(ex. studyplus-MIoh79q7pfMbTUVA3BNsSeTaZRcOK3yg )
#import "SPLStudyplusDelegate.h"
@interface YourClass<SPLStudyplusDelegate>
-(BOOL)openURL:(NSURL*)url;
@end
#import "SPLStudyplus.h"
static NSString * const ConsumerKey = @"Your Studyplus consumer key";
static NSString * const ConsumerSecret = @"Your Studyplus consumer secret";
static SPLStudyplus *studyplus;
@implementation YourClass
-(id) init {
if (self = [super init]) {
studyplus = [SPLStudyplus studyplusWithConsumerKey:ConsumerKey
andConsumerSecret:ConsumerSecret];
studyplus.delegate = self;
}
return self;
}
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [yourClassObject openURL:url];
}
@interface YourClass
-(BOOL)openURL:(NSURL*)url;
@end
@implementation YourClass
-(void) doAuth {
[studyplus auth];
}
-(void) doLogin
{
[studyplus login];
}
// Called by AppDelegate
-(BOOL) openURL:(NSURL*)url
{
return [studyplus openURL:url];
}
// callback methods
-(void)studyplusDidConnect:(SPLStudyplus*)studyplus
{
NSLog(@"Auth or Login succeeded");
}
-(void)studyplusDidFailToConnect:(SPLStudyplus*)studyplus withError:(NSError*)error
{
NSLog(@"Auth or Login failed");
}
- (void)studyplusDidCancel:(SPLStudyplus*)studyplus
{
NSLog(@"Auth or Login canceled");
}
-(void)post
{
// Create new study record.
SPLStudyplusRecord *studyplusRecord =
[SPLStudyplusRecord
/**
@see SPLStopwatch
*/
recordWithDuration:[studyplus.stopwatch elapsedSeconds]
/** You can add optional info.
options:@{
// Time the learning is ended. 学習を終えた日時。
@"recordedAt" : [NSDate date],
// Studyplus timeline comment. Studyplusのタイムライン上で表示されるコメント。
@"comment" : @"アプリ◯◯で勉強しました!!",
// @see SPLStudyplusRecordAmount
@"amount" : [SPLStudyplusRecordAmount amount:100],
}
*/
];
// post
[studyplus postStudyRecord:studyplusRecord];
}
// callback methods
-(void)studyplusDidPostStudyRecord:(SPLStudyplus*)studyplus
{
NSLog(@"Post to Studyplus succeeded");
}
-(void)studyplusDidFailToPostStudyRecord:(SPLStudyplus*)studyplus withError:(NSError*)error
{
// see @SPLStudyplusError with error.code.
NSLog(@"Post to Studyplus failed");
}
- StudyplusSDK/SPLStudyplus.h
- StudyplusSDK/SPLStudyplusDelegate.h
- StudyplusSDK/SPLStudyplusRecord.h
- StudyplusSDK/SPLStudyplusRecordAmount.h
- Run
pod try StudyplusSDK
or See Demo directory and open StudyplusSDKDemo/StudyplusSDKDemo.xcodeproj - Edit consumer key and consumer secret in Viewcontroller.m
- Set URL Type with your consumer key
- Run
- Do "Auth" and "Post record", and see public timeline at http://studyplus.jp