Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

studyplus/Studyplus-iOS-SDK

Open more actions menu

Repository files navigation

StudyplusSDK

Studyplus iOS SDK

Requirements

Dependency

Install

CocoaPods (Recommended)

# Edit your podfile
platform :ios, '7.0'
pod 'StudyplusSDK'

and run pod install

Manual install

By library and headers

  1. Get StudyplusSDK.
  • git clone https://github.com/studyplus/Studyplus-iOS-SDK or download zip from this page.
  1. Copy build/Release/deliverables/StudyplusSDK to your project.
  2. Install AFNetworking and UICKeyChainStore too.
  3. Add required frameworks(i.e. Security.framework, SystemConfiguration.framework, MobileCoreServices, CoreGraphics etc). See AFNetworking and UICKeyChainStore.

By source copy (iOS 7 required)

  1. Get StudyplusSDK
  • git clone https://github.com/studyplus/Studyplus-iOS-SDK or download zip from this page.
  1. Copy Studyplus-iOS-SDK/StudyplusSDK directory to your project.
  2. Install AFNetworking and UICKeyChainStore too.

Usage

Set up custom URL scheme

set "studyplus-{your consumer key}" to URL Types.
(ex. studyplus-MIoh79q7pfMbTUVA3BNsSeTaZRcOK3yg )

xcode

Initialize

#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;
}

Auth or Login

@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");
} 

Post study record to Studyplus

-(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");
}

More info about SDK interface

  • StudyplusSDK/SPLStudyplus.h
  • StudyplusSDK/SPLStudyplusDelegate.h
  • StudyplusSDK/SPLStudyplusRecord.h
  • StudyplusSDK/SPLStudyplusRecordAmount.h

Demo app

demo

  1. Run pod try StudyplusSDK or See Demo directory and open StudyplusSDKDemo/StudyplusSDKDemo.xcodeproj
  2. Edit consumer key and consumer secret in Viewcontroller.m
  3. Set URL Type with your consumer key
  4. Run
  5. Do "Auth" and "Post record", and see public timeline at http://studyplus.jp

License

MIT License.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.