Swiftpack.co - studyplus/Studyplus-iOS-SDK as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by studyplus.
studyplus/Studyplus-iOS-SDK 4.0.0
Studyplus iOS SDK for Swift
⭐️ 2
🕓 2 years ago
iOS
.package(url: "https://github.com/studyplus/Studyplus-iOS-SDK.git", from: "4.0.0")

StudyplusSDK

Requirements

  • iOS 11.0以上
  • Swift 5.1以上

Install

Swift Package Manager

https://github.com/studyplus/Studyplus-iOS-SDKを追加してください。

CocoaPods

Podfileに StudyplusSDK を追加してください。

use_frameworks!
pod 'StudyplusSDK'

Usage

https://info.studyplus.co.jp/contact/studyplus-apiよりStudypluAPIの申請を最初に行ってください。 審査後、consumer keyconsumer secretの2つをメールにて送付いたします。

custom URL schemeの設定

studyplus-{consumer key} を URL Typesに追加してください。

xcode

consumer keyconsumer secretの追加

Info.plistにconsumer keyconsumer secretを追加してください。

<key>StudyplusSDK</key>
<dict>
  <key>consumerKey</key>
  <string>set_your_consumerKey</string>
  <key>consumerSecret</key>
  <string>set_your_consumerSecret</string>
</dict>

LSApplicationQueriesSchemes

Studyplusアプリがインストールされているかチェックできるようにするため、Info.plistのLSApplicationQueriesSchemesstudyplusを追加してください。

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>studyplus</string>
</array>

Initialize

import StudyplusSDK

class ViewController: UIViewController, StudyplusLoginDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
        Studyplus.shared.delegate = self
    }
}

Login

import StudyplusSDK

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        return Studyplus.shared.handle(url)
    }
}
import StudyplusSDK

class ViewController: UIViewController, StudyplusLoginDelegate {
    func login() {
        Studyplus.shared.login()
    }

    func studyplusLoginSuccess() {
        // on success
    }

    func studyplusLoginFail(error: StudyplusLoginError) {
        // on failed
    }
}

学習記録の投稿

let record = StudyplusRecord(duration: Int(duration),
                                amount: 10,
                                comment: "Today, I studied like anything.",
                                recordDatetime: Date())

Studyplus.shared.post(record, completion: { result in
    switch result {
    case .failure(let error):
        // handle error
    case .success:
        // finish post
    }
})

Demo app

demo

  • Set studyplus-{your consumer key} to URL Types in Demo.
  • Set consumerKey and consumerSecret in Info.plist of Demo.
  • Select Demo Scheme and Run.

License

The MIT License (MIT)

Copyright (c) 2021 Studyplus inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

GitHub

link
Stars: 2
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

4.0.0
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics