1
- StudyplusSDK-V2
2
- =======
3
-
4
- StudyplusSDK-V2 is [ Studyplus iOS SDK] ( https://github.com/studyplus/Studyplus-iOS-SDK ) for Swift.
1
+ # StudyplusSDK-V2
5
2
6
3
## Requirements
7
4
8
- * iOS 9.0 or above
9
- * Swift 4.0 or above
10
-
11
- ## Dependency
12
- * [ KeychainAccess] ( https://github.com/kishikawakatsumi/KeychainAccess )
5
+ * iOS 11.0以上
6
+ * Swift 5.1以上
13
7
14
8
## Install
15
9
10
+ ### [ Swift Package Manager] ( https://github.com/apple/swift-package-manager/ )
11
+
12
+ < https://github.com/studyplus/Studyplus-iOS-SDK-V2 > を追加してください。
13
+
16
14
### [ CocoaPods] ( https://cocoapods.org/ )
17
- Add the following line to your Podfile:
18
- ``` ruby
19
- use_frameworks!
20
15
21
- target ' YOUR_TARGET_NAME' do
22
- pod ' StudyplusSDK-V2'
23
- end
24
- ```
16
+ Podfileに ` StudyplusSDK-V2 ` を追加してください。
25
17
26
- ### [ Carthage] ( https://github.com/Carthage/Carthage )
27
- Add the following line to your Cartfile:
28
- ``` swift
29
- github " studyplus/Studyplus-iOS-SDK-V2"
18
+ ``` ruby
19
+ use_frameworks!
20
+ pod ' StudyplusSDK-V2'
30
21
```
31
22
32
23
## Usage
33
24
34
- - If you don't have consumerKey and consumerSecret, please contact https://info.studyplus.co.jp/contact/studyplus-api
25
+ < https://info.studyplus.co.jp/contact/studyplus-api > よりStudypluAPIの申請を最初に行ってください。
26
+ 審査後、` consumer key ` と` consumer secret ` の2つをメールにて送付いたします。
35
27
36
- ### ① Set up custom URL scheme
28
+ ### custom URL schemeの設定
37
29
38
- - set __ studyplus-* {your consumer key}* __ to URL Types. (ex. studyplus-MIoh79q7pfMbTUVA3BNsSeTaZRcOK3yg )
30
+ __ studyplus-* {consumer key}* __ を URL Typesに追加してください。
39
31
40
32
![ xcode] ( https://github.com/studyplus/Studyplus-iOS-SDK-V2/blob/master/docs/set_url_scheme.png )
41
33
42
- ### ② Set up consumerKey and consumerSecret
34
+ ### ` consumer key ` と ` consumer secret ` の追加
43
35
44
- - set __ consumerKey __ and __ consumerSecret __ in your Info.plist.
36
+ Info.plistに ` consumer key ` と ` consumer secret ` を追加してください。
45
37
46
- ```
38
+ ``` txt
47
39
<key>StudyplusSDK</key>
48
40
<dict>
49
41
<key>consumerKey</key>
@@ -53,11 +45,11 @@ github "studyplus/Studyplus-iOS-SDK-V2"
53
45
</dict>
54
46
```
55
47
56
- ### ③ Set up LSApplicationQueriesSchemes
48
+ ### LSApplicationQueriesSchemes
57
49
58
- - Set LSApplicationQueriesSchemes in your info.plist for checking if studyplus is installed.
50
+ Studyplusアプリがインストールされているかチェックできるようにするため、Info.plistの ` LSApplicationQueriesSchemes ` に ` studyplus ` を追加してください。
59
51
60
- ```
52
+ ``` txt
61
53
<key>LSApplicationQueriesSchemes</key>
62
54
<array>
63
55
<string>studyplus</string>
@@ -66,94 +58,63 @@ github "studyplus/Studyplus-iOS-SDK-V2"
66
58
67
59
### Initialize
68
60
69
- ``` Swift
70
-
71
- // when carthage is StudyplusSDK, cocoapods is StudyplusSDK_V2
72
- import StudyplusSDK_V2
61
+ ``` swift
62
+ import StudyplusSDK
73
63
74
64
class ViewController : UIViewController , StudyplusLoginDelegate {
75
-
76
65
override func viewDidLoad () {
77
66
super .viewDidLoad ()
78
67
Studyplus.shared .delegate = self
79
68
}
80
-
81
- // ...
82
69
}
83
70
```
84
71
85
72
### Login
86
- ``` Swift
87
73
88
- // when carthage is StudyplusSDK, cocoapods is StudyplusSDK_V2
89
- import StudyplusSDK_V2
74
+ ``` swift
75
+ import StudyplusSDK
90
76
91
77
class AppDelegate : UIResponder , UIApplicationDelegate {
92
-
93
- func application (_ app : UIApplication, open url : URL, options : [UIApplicationOpenURLOptionsKey : Any ] = [: ]) -> Bool {
94
- return Studyplus.shared .handle (appDelegateUrl : url)
78
+ func application (_ app : UIApplication, open url : URL, options : [UIApplication.OpenURLOptionsKey: Any ] = [: ]) -> Bool {
79
+ return Studyplus.shared .handle (url)
95
80
}
96
81
}
97
82
```
98
83
99
- ``` Swift
100
-
101
- // when carthage is StudyplusSDK, cocoapods is StudyplusSDK_V2
102
- import StudyplusSDK_V2
84
+ ``` swift
85
+ import StudyplusSDK
103
86
104
87
class ViewController : UIViewController , StudyplusLoginDelegate {
105
-
106
- // ...
107
-
108
- // MARK: - Login
109
-
110
- @IBAction func loginButton (_ sender : UIButton) {
88
+ func login () {
111
89
Studyplus.shared .login ()
112
90
}
113
91
114
- // MARK: - StudyplusLoginDelegate
115
-
116
- func studyplusDidSuccessToLogin () {
117
- // do something
118
- }
119
-
120
- func studyplusDidFailToLogin (error : StudyplusError) {
121
- // do something
92
+ func studyplusLoginSuccess () {
93
+ // on success
122
94
}
123
95
124
- func studyplusDidCancelToLogin ( ) {
125
- // do something
96
+ func studyplusLoginFail ( error : StudyplusLoginError ) {
97
+ // on failed
126
98
}
127
99
}
128
100
```
129
101
130
- ### Post studyRecord to Studyplus
131
-
132
- ``` Swift
102
+ ### 学習記録の投稿
133
103
134
- // when carthage is StudyplusSDK, cocoapods is StudyplusSDK_V2
135
- import StudyplusSDK_V2
136
-
137
- class ViewController : UIViewController , StudyplusLoginDelegate {
138
-
139
- // ...
140
-
141
- // MARK: - Post studyRecord to Studyplus
142
-
143
- @IBAction func postStudyRecordButton (_ sender : UIButton) {
144
- let recordAmount: StudyplusRecordAmount = StudyplusRecordAmount (amount : 10 )
145
- let record: StudyplusRecord = StudyplusRecord (duration : duration, recordedAt : Date (), amount : recordAmount, comment : " Today, I studied like anything." )
146
-
147
- Studyplus.shared .post (studyRecord : record, success : {
148
-
149
- // do something
150
-
151
- }, failure : { error in
152
-
153
- print (" Error Code: \( error.code () ) , Message: \( error.message () ) " )
154
- })
104
+ ``` swift
105
+ let record = StudyplusRecord (duration : Int (duration),
106
+ amount : 10 ,
107
+ comment : " Today, I studied like anything." ,
108
+ recordDatetime : Date ())
109
+
110
+ Studyplus.shared .post (record, completion : { result in
111
+ switch result {
112
+ case .failure (let error):
113
+ // handle error
114
+ case .success :
115
+ // finish post
155
116
}
156
- }
117
+ })
157
118
```
158
119
159
120
## Demo app
@@ -166,4 +127,26 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
166
127
167
128
## License
168
129
169
- - [ MIT License.] ( http://opensource.org/licenses/mit-license.php )
130
+ ``` txt
131
+ The MIT License (MIT)
132
+
133
+ Copyright (c) 2021 Studyplus inc.
134
+
135
+ Permission is hereby granted, free of charge, to any person obtaining a copy
136
+ of this software and associated documentation files (the "Software"), to deal
137
+ in the Software without restriction, including without limitation the rights
138
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
139
+ copies of the Software, and to permit persons to whom the Software is
140
+ furnished to do so, subject to the following conditions:
141
+
142
+ The above copyright notice and this permission notice shall be included in
143
+ all copies or substantial portions of the Software.
144
+
145
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
146
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
147
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
148
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
149
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
150
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
151
+ THE SOFTWARE.
152
+ ```
0 commit comments