Skip to content

Commit 2e563e9

Browse files
Merge pull request #61 from frontegg/bump-native-versions
2 parents ed9e92f + 54587c8 commit 2e563e9

16 files changed

Lines changed: 747 additions & 74 deletions

File tree

FronteggRN.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Pod::Spec.new do |s|
2020
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
2121
if respond_to?(:install_modules_dependencies, true)
2222
install_modules_dependencies(s)
23-
s.dependency "FronteggSwift", "1.2.34"
23+
s.dependency "FronteggSwift", "1.2.76"
2424
else
2525
s.dependency "React-Core"
26-
s.dependency "FronteggSwift", "1.2.34"
26+
s.dependency "FronteggSwift", "1.2.76"
2727

2828
# Don't install the dependencies when we run `pod install` in the old architecture.
2929
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then

android/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ android {
5555
}
5656

5757
compileOptions {
58-
sourceCompatibility JavaVersion.VERSION_1_8
59-
targetCompatibility JavaVersion.VERSION_1_8
58+
sourceCompatibility JavaVersion.VERSION_11
59+
targetCompatibility JavaVersion.VERSION_11
6060
}
6161

62+
kotlinOptions {
63+
jvmTarget = "11"
64+
}
6265
}
6366

6467
repositories {
@@ -77,7 +80,7 @@ dependencies {
7780
implementation "androidx.browser:browser:1.8.0"
7881
implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1'
7982
implementation 'com.google.code.gson:gson:2.10.1'
80-
implementation 'com.frontegg.sdk:android:1.2.33'
83+
implementation 'com.frontegg.sdk:android:1.3.18'
8184
}
8285

8386
if (isNewArchitectureEnabled()) {

android/src/main/java/com/frontegg/reactnative/FronteggRNModule.kt

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import com.facebook.react.bridge.ReactMethod
1010
import com.facebook.react.bridge.WritableMap
1111
import com.facebook.react.common.LifecycleState
1212
import com.facebook.react.modules.core.DeviceEventManagerModule
13-
import com.frontegg.android.FronteggApp
14-
import com.frontegg.android.FronteggAuth
13+
import com.frontegg.android.fronteggAuth
1514
import io.reactivex.rxjava3.core.Observable
1615
import io.reactivex.rxjava3.disposables.Disposable
1716

@@ -20,23 +19,16 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
2019
ReactContextBaseJavaModule(reactContext) {
2120
private val fronteggConstants: FronteggConstants
2221
private var disposable: Disposable? = null
22+
23+
private val auth get() = reactContext.applicationContext.fronteggAuth
24+
2325
override fun getName(): String {
2426
return NAME
2527
}
2628

2729
init {
2830
fronteggConstants = reactContext.fronteggConstants
29-
30-
31-
32-
FronteggApp.init(
33-
fronteggConstants.baseUrl,
34-
fronteggConstants.clientId,
35-
reactContext.applicationContext,
36-
applicationId = fronteggConstants.applicationId,
37-
useAssetsLinks = fronteggConstants.useAssetsLinks,
38-
useChromeCustomTabs = fronteggConstants.useChromeCustomTabs,
39-
)
31+
// SDK 1.3+ auto-initializes from BuildConfig when first accessing context.fronteggAuth
4032
}
4133

4234
private fun sendEvent(
@@ -58,14 +50,14 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
5850
this.disposable!!.dispose()
5951
}
6052
this.disposable = Observable.mergeArray(
61-
FronteggAuth.instance.accessToken.observable,
62-
FronteggAuth.instance.refreshToken.observable,
63-
FronteggAuth.instance.refreshingToken.observable,
64-
FronteggAuth.instance.user.observable,
65-
FronteggAuth.instance.isAuthenticated.observable,
66-
FronteggAuth.instance.isLoading.observable,
67-
FronteggAuth.instance.initializing.observable,
68-
FronteggAuth.instance.showLoader.observable,
53+
auth.accessToken.observable,
54+
auth.refreshToken.observable,
55+
auth.refreshingToken.observable,
56+
auth.user.observable,
57+
auth.isAuthenticated.observable,
58+
auth.isLoading.observable,
59+
auth.initializing.observable,
60+
auth.showLoader.observable,
6961
).subscribe {
7062
notifyChanges()
7163
}
@@ -85,14 +77,14 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
8577
return
8678
}
8779
handler.removeCallbacks(eventRunnable)
88-
val accessToken = FronteggAuth.instance.accessToken.value
89-
val refreshToken = FronteggAuth.instance.refreshToken.value
90-
val refreshingToken = FronteggAuth.instance.refreshingToken.value
91-
val user = FronteggAuth.instance.user.value
92-
val isAuthenticated = FronteggAuth.instance.isAuthenticated.value
93-
val isLoading = FronteggAuth.instance.isLoading.value
94-
val initializing = FronteggAuth.instance.initializing.value
95-
val showLoader = FronteggAuth.instance.showLoader.value
80+
val accessToken = auth.accessToken.value
81+
val refreshToken = auth.refreshToken.value
82+
val refreshingToken = auth.refreshingToken.value
83+
val user = auth.user.value
84+
val isAuthenticated = auth.isAuthenticated.value
85+
val isLoading = auth.isLoading.value
86+
val initializing = auth.initializing.value
87+
val showLoader = auth.showLoader.value
9688

9789
val params = Arguments.createMap().apply {
9890

@@ -112,7 +104,7 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
112104

113105
@ReactMethod
114106
fun logout() {
115-
FronteggAuth.instance.logout()
107+
auth.logout()
116108
}
117109

118110
@ReactMethod
@@ -128,37 +120,37 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
128120
@ReactMethod
129121
fun login(loginHint: String?, promise: Promise) {
130122
val activity = currentActivity
131-
FronteggAuth.instance.login(activity!!, loginHint) {
123+
auth.login(activity!!, loginHint) {
132124
promise.resolve("")
133125
}
134126
}
135127

136128
@ReactMethod
137129
fun switchTenant(tenantId: String, promise: Promise) {
138-
FronteggAuth.instance.switchTenant(tenantId) {
130+
auth.switchTenant(tenantId) {
139131
promise.resolve(tenantId)
140132
}
141133
}
142134

143135
@ReactMethod
144136
fun directLoginAction(type: String, data: String, ephemeralSession: Boolean, promise: Promise) {
145137
val activity = currentActivity
146-
FronteggAuth.instance.directLoginAction(activity!!, type, data)
138+
auth.directLoginAction(activity!!, type, data)
147139
promise.resolve(true)
148140
}
149141

150142
@ReactMethod
151143
fun refreshToken(promise: Promise) {
152-
FronteggAuth.instance.refreshTokenIfNeeded()
144+
auth.refreshTokenIfNeeded()
153145
promise.resolve("")
154146
}
155147

156148
@ReactMethod
157149
fun loginWithPasskeys(promise: Promise) {
158150
val activity = currentActivity
159-
FronteggAuth.instance.loginWithPasskeys(activity!!) {
160-
if (it != null) {
161-
promise.reject(it)
151+
auth.loginWithPasskeys(activity!!) { error ->
152+
if (error != null) {
153+
promise.reject(error)
162154
} else {
163155
promise.resolve("")
164156
}
@@ -168,7 +160,7 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
168160
@ReactMethod
169161
fun requestAuthorize(refreshToken: String, deviceTokenCookie: String?, promise: Promise) {
170162
try {
171-
FronteggAuth.instance.requestAuthorize(refreshToken, deviceTokenCookie) { result ->
163+
auth.requestAuthorize(refreshToken, deviceTokenCookie) { result ->
172164
result.fold(
173165
onSuccess = { user ->
174166
promise.resolve(user.toReadableMap())
@@ -188,9 +180,9 @@ class FronteggRNModule(val reactContext: ReactApplicationContext) :
188180
@ReactMethod
189181
fun registerPasskeys(promise: Promise) {
190182
val activity = currentActivity
191-
FronteggAuth.instance.registerPasskeys(activity!!) {
192-
if (it != null) {
193-
promise.reject(it)
183+
auth.registerPasskeys(activity!!) { error ->
184+
if (error != null) {
185+
promise.reject(error)
194186
} else {
195187
promise.resolve("")
196188
}

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ android {
123123
dependencies {
124124
// The version of react-native is set by the React Native Gradle Plugin
125125
implementation("com.facebook.react:react-android")
126-
126+
implementation 'com.frontegg.sdk:android:1.3.18'
127127
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
128128
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
129129
exclude group:'com.squareup.okhttp3', module:'okhttp'

0 commit comments

Comments
 (0)