Skip to content

Commit c25a475

Browse files
authored
Merge pull request xmartlabs#49 from xmartlabs/bugfix/android_kotlin
Bugfix/android kotlin
2 parents 87b36b6 + c947945 commit c25a475

File tree

7 files changed

+49
-44
lines changed

7 files changed

+49
-44
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
"code"
2424
]
2525
},
26+
{
27+
"login": "nicoache1",
28+
"name": "Nicolas Hernandez",
29+
"avatar_url": "https://avatars0.githubusercontent.com/u/26419582?v=4",
30+
"profile": "https://github.com/nicoache1",
31+
"contributions": [
32+
"code",
33+
"review"
34+
]
35+
},
2636
{
2737
"login": "santiagofm",
2838
"name": "Santiago Fernández",

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This library includes:
1616
## Requirements
1717

1818
- React native `>=0.61.1`
19+
- iOS 10.0 or later as the development target
20+
- Android `minSdkVersion` set to 17 or higher
1921
- [LINE developer account](https://developers.line.biz/console/) with a channel created.
2022

2123
## Migration from v1.x.x
@@ -56,13 +58,27 @@ First, install the npm package with yarn. _Autolink_ is automatic.
5658

5759
Inside your `AppDelegate.m`, setup the line sdk by passing the channel id obtained.
5860

61+
1. Add `platform :ios, '10.0'` in `Podfile` line:1
62+
2. Enable `use_frameworks!` in `Podfile` line:3
63+
3. Comment the code related to flipper, flipper doesn't support `use_frameworks!` !
64+
4. Add this code to your `AppDelegate.m`
65+
5966
```objc
6067
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
6168
...
6269
[LineLogin setupWithChannelID:@"YOUR_CHANNELL_ID" universalLinkURL:nil];
63-
```
6470

65-
Copy `openURL` and `continueUserActivity` functions from the [example app](#example). They don't need any further modification.
71+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
72+
{
73+
return [LineLogin application:app open:url options:options];
74+
}
75+
76+
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
77+
{
78+
BOOL handledLine = [LineLogin application:application continue:userActivity restorationHandler:restorationHandler];
79+
return handledLine;
80+
}
81+
```
6682
6783
#### Using Swift
6884
@@ -85,13 +101,16 @@ Don't forget to add `application` function, as line's instructions indicate.
85101

86102
### Android Setup
87103

88-
1. Follow all the configuration steps in [Line's Android integration guide](https://developers.line.me/en/docs/line-login/android/integrate-line-login/)
104+
1. Follow all the configuration steps in [Line's Android integration guide](https://developers.line.biz/en/docs/android-sdk/integrate-line-login/)
89105
2. Add the string `line_channel_id` to your strings file with the the channel id that you have on your line console.
90106

91107
```xml
92108
<string name="line_channel_id" translatable="false">Your channel id here</string>
93109
```
94110

111+
3. Add `minSdkVersion = 17` in `android/build.gradle`
112+
4. In your manifest add `xmlns:tools="http://schemas.android.com/tools"` in your `manifest` tag and also `tools:replace="android:allowBackup"` in your `application` tag
113+
95114
## API
96115

97116
First, require the `LineLogin` module:
@@ -154,23 +173,6 @@ The following objects are returned on the methods described above:
154173
/// of the access token. This value might not be the actual expiration time because this value depends
155174
/// on the system time of the device when `createdAt` is determined.
156175
expires_in: String
157-
158-
/// The creation time of the access token. It is the system time of the device that receives the current
159-
/// access token.
160-
createdAt: String
161-
162-
/// The raw string value of the ID token bound to the access token. The value exists only if the access token
163-
/// is obtained with the `.openID` permission.
164-
id_token?: String
165-
166-
/// The refresh token bound to the access token.
167-
/// `refreshToken` is not publicly provided anymore. You should not access or store it yourself.
168-
refresh_token: String
169-
170-
token_type: String
171-
172-
/// Permissions separated by spaces
173-
scope: String
174176
}
175177
```
176178

@@ -205,6 +207,9 @@ The following objects are returned on the methods described above:
205207
/// `LoginManagerOption` object when the user logs in. For more information, see Linking a bot with your LINE
206208
/// Login channel at https://developers.line.me/en/docs/line-login/web/link-a-bot/.
207209
friendshipStatusChanged?: boolean
210+
/// The raw string value of the ID token bound to the access token. The value exists only if the access token
211+
/// is obtained with the `.openID` permission.
212+
lineIdToken?: String
208213
/// The `nonce` value when requesting ID Token during login process. Use this value as a parameter when you
209214
/// verify the ID Token against the LINE server. This value is `null` if `.openID` permission is not requested.
210215
IDTokenNonce?: String
@@ -229,7 +234,7 @@ The following objects are returned on the methods described above:
229234
{
230235
email = 'email',
231236
/// The permission to get an ID token in the login response.
232-
openID = 'openID',
237+
openID = 'openid',
233238

234239
/// The permission to get the user's profile including the user ID, display name, and the profile image
235240
/// URL in the login response.
@@ -312,6 +317,7 @@ If you want to see `@xmartlabs/react-native-line` in action, just move into the
312317
<tr>
313318
<td align="center"><a href="https://github.com/eb16"><img src="https://avatars0.githubusercontent.com/u/20881388?v=4" width="100px;" alt=""/><br /><sub><b>Emiliano Botti</b></sub></a><br /><a href="https://github.com/eb16/react-native-line/commits?author=eb16" title="Code">💻</a></td>
314319
<td align="center"><a href="https://github.com/Joaguirrem"><img src="https://avatars2.githubusercontent.com/u/17858453?v=4" width="100px;" alt=""/><br /><sub><b>Joaquín Aguirre</b></sub></a><br /><a href="https://github.com/eb16/react-native-line/commits?author=Joaguirrem" title="Code">💻</a></td>
320+
<td align="center"><a href="https://github.com/nicoache1"><img src="https://avatars0.githubusercontent.com/u/26419582?v=4" width="100px;" alt=""/><br /><sub><b>Nicolas Hernandez</b></sub></a><br /><a href="https://github.com/eb16/react-native-line/commits?author=nicoache1" title="Code">💻</a> <a href="https://github.com/eb16/react-native-line/pulls?q=is%3Apr+reviewed-by%3Anicoache1" title="Reviewed Pull Requests">👀</a></td>
315321
<td align="center"><a href="https://github.com/santiagofm"><img src="https://avatars0.githubusercontent.com/u/6749415?v=4" width="100px;" alt=""/><br /><sub><b>Santiago Fernández</b></sub></a><br /><a href="#projectManagement-santiagofm" title="Project Management">📆</a> <a href="https://github.com/eb16/react-native-line/pulls?q=is%3Apr+reviewed-by%3Asantiagofm" title="Reviewed Pull Requests">👀</a><a href="https://github.com/eb16/react-native-line/commits?author=santiagofm" title="Code">💻</a></td>
316322
<td align="center"><a href="https://github.com/matir91"><img src="https://avatars2.githubusercontent.com/u/8472881?v=4" width="100px;" alt=""/><br /><sub><b>Matías Irland</b></sub></a><br /><a href="https://github.com/eb16/react-native-line/pulls?q=is%3Apr+reviewed-by%3Amatir91" title="Reviewed Pull Requests">👀</a></td>
317323
</tr>

RNLine.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Pod::Spec.new do |s|
1111
s.authors = package['author']
1212
s.homepage = package['homepage']
1313
s.platform = :ios, "10.0"
14+
s.swift_version = '5.0'
1415

1516
s.source = { :git => "" }
1617
s.source_files = "ios/**/*.{h,m,swift}"

android/src/main/java/com/xmartlabs/rnline/RNLine.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import com.linecorp.linesdk.LineProfile
2323
enum class LoginArguments(val key: String) {
2424
SCOPES("scopes"),
2525
ONLY_WEB_LOGIN("onlyWebLogin"),
26-
BOT_PROMPT("onlyWebLogin")
26+
BOT_PROMPT("botPrompt")
2727
}
2828

2929
class RNLine(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
@@ -222,8 +222,7 @@ class RNLine(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule
222222
private fun parseAccessToken(accessToken: LineAccessToken): WritableMap = Arguments.makeNativeMap(
223223
mapOf(
224224
"access_token" to accessToken.tokenString,
225-
"expires_in" to accessToken.expiresInMillis,
226-
"id_token" to ""
225+
"expires_in" to accessToken.expiresInMillis
227226
)
228227
)
229228

@@ -258,7 +257,9 @@ class RNLine(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule
258257
"scope" to loginResult.lineCredential?.scopes?.let {
259258
Scope.join(it)
260259
},
261-
"friendshipStatusChanged" to loginResult.friendshipStatusChanged
260+
"lineIdToken" to loginResult.lineIdToken?.rawString,
261+
"friendshipStatusChanged" to loginResult.friendshipStatusChanged,
262+
"IDTokenNonce" to loginResult.lineIdToken?.nonce
262263
)
263264
)
264265

index.d.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,6 @@ export interface AccessToken {
1414
/// of the access token. This value might not be the actual expiration time because this value depends
1515
/// on the system time of the device when `createdAt` is determined.
1616
expires_in: String
17-
18-
/// The creation time of the access token. It is the system time of the device that receives the current
19-
/// access token.
20-
createdAt: String
21-
22-
/// The raw string value of the ID token bound to the access token. The value exists only if the access token
23-
/// is obtained with the `.openID` permission.
24-
id_token?: String
25-
26-
/// The refresh token bound to the access token.
27-
/// `refreshToken` is not publicly provided anymore. You should not access or store it yourself.
28-
refresh_token: String
29-
30-
token_type: String
31-
32-
/// Permissions separated by spaces
33-
scope: String
3417
}
3518

3619
export interface AccessTokenVerifyResult {
@@ -58,7 +41,7 @@ export interface LoginArguments {
5841
export enum LoginPermission {
5942
email = 'email',
6043
/// The permission to get an ID token in the login response.
61-
openID = 'openID',
44+
openID = 'openid',
6245

6346
/// The permission to get the user's profile including the user ID, display name, and the profile image
6447
/// URL in the login response.
@@ -81,6 +64,9 @@ export interface LoginResult {
8164
/// The `nonce` value when requesting ID Token during login process. Use this value as a parameter when you
8265
/// verify the ID Token against the LINE server. This value is `null` if `.openID` permission is not requested.
8366
IDTokenNonce?: String
67+
/// The raw string value of the ID token bound to the access token. The value exists only if the access token
68+
/// is obtained with the `.openID` permission.
69+
lineIdToken?: String
8470
}
8571

8672
export interface UserProfile {

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const BotPrompt = {
88
}
99
const LoginPermission = {
1010
email: 'email',
11-
openID: 'openID',
11+
openID: 'openid',
1212
profile: 'profile',
1313
}
1414

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Emiliano Botti <emiliano@xmartlabs.com>",
99
"Joaquin Aguirre <joaquin.aguirre@xmartlabs.com>",
1010
"Santiago Fernandez <santiagofm@xmartlabs.com>",
11+
"Nicolás Hernández <nicolas@xmartlabs.com>",
1112
"Marco Fiorito <marco@xmartlabs.com>"
1213
],
1314
"version": "2.0.1",

0 commit comments

Comments
 (0)