このリポジトリはアーカイブされたため、Studyplus-iOS-SDKを参照してください。
- iOS 11.0以上
- Swift 5.1以上
https://github.com/studyplus/Studyplus-iOS-SDK-V2を追加してください。
Podfileに StudyplusSDK-V2
を追加してください。
use_frameworks!
pod 'StudyplusSDK-V2'
https://info.studyplus.co.jp/contact/studyplus-apiよりStudypluAPIの申請を最初に行ってください。
審査後、consumer key
とconsumer secret
の2つをメールにて送付いたします。
studyplus-{consumer key} を URL Typesに追加してください。
Info.plistにconsumer key
とconsumer secret
を追加してください。
<key>StudyplusSDK</key>
<dict>
<key>consumerKey</key>
<string>set_your_consumerKey</string>
<key>consumerSecret</key>
<string>set_your_consumerSecret</string>
</dict>
Studyplusアプリがインストールされているかチェックできるようにするため、Info.plistのLSApplicationQueriesSchemes
にstudyplus
を追加してください。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>studyplus</string>
</array>
import StudyplusSDK
class ViewController: UIViewController, StudyplusLoginDelegate {
override func viewDidLoad() {
super.viewDidLoad()
Studyplus.shared.delegate = self
}
}
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
}
})
- Set studyplus-{your consumer key} to URL Types in Demo.
- Set consumerKey and consumerSecret in Info.plist of Demo.
- Select Demo Scheme and Run.
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.