Skip to content
This repository was archived by the owner on Mar 26, 2023. It is now read-only.

Commit f082d84

Browse files
authored
Migrate plugin to null safety (#45)
* updated dependencies * Updated dependencies * migrated firebase_auth_oauth_platform_interface * migrated firebase_auth_oauth_web * migrated firebase_auth_oauth * updated example * fixed premature invocation for Firebase.app that's happening before Firebase.initialise() is called * Update minimum version to iOS 10 * Updated Android to include androidx.browser dependency and added queries to manifest * published platform_interface * published web * published plugin update * Updated gitignore
1 parent a16807b commit f082d84

32 files changed

+183
-1276
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
build/
88
*.iml
99
.flutter-plugins
10-
10+
*.lock

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ OAuth flows are performed by opening pop-up on top of the application to allow t
1515
dependencies:
1616
flutter:
1717
sdk: flutter
18-
firebase_auth: ^0.20.0+1
19-
firebase_core: ^0.7.0
20-
firebase_auth_oauth: ^0.2.4
18+
firebase_auth: ^1.0.0
19+
firebase_core: ^1.0.0
20+
firebase_auth_oauth: ^1.0.0
2121
```
2222

2323
- Then in your project just call

firebase_auth_oauth/CHANGELOG.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,73 @@
1+
## 1.0.0
2+
3+
* Migrated to null safety
4+
* Updated `firebase_auth` to Version ^1.0.0
5+
* Updated `firebase_core` to Version ^1.0.0
6+
17
## 0.2.4
8+
29
* Updated `firebase_auth` to Version ^0.20.0+1
310
* Updated `firebase_core` to Version ^0.7.0
411

512
## 0.2.3
13+
614
* Replace CryptoKit pod with Apple's CryptoKit framework
715

816
## 0.2.2
9-
* Fixed crash on iOS when using Microsoft sign in. Thanks
10-
to [@camillobucciarelli](https://github.com/camillobucciarelli).
17+
18+
* Fixed crash on iOS when using Microsoft sign in. Thanks to [@camillobucciarelli](https://github.com/camillobucciarelli).
1119

1220
## 0.2.1
1321
* Fixed Firebase not initialised issue when using this plugin
1422

1523
## 0.2.0
24+
1625
* Migrated to `firebase_auth` ^0.18.0+1
1726
* Migrated to `firebase_auth` ^0.5.0
1827
* Added `linkExistingUserWithCredentials` to link existing user with OAuth credentials
1928

2029
## 0.1.1+1
30+
2131
* Fixed type in README
2232

2333
## 0.1.1
34+
2435
* Improved error handling across iOS and Android
2536
* Consistent error behaviour across platforms
2637

2738
## 0.1.0+8
39+
2840
* Updated firebase_auth to Version ^0.16.1
2941
* Updated firebase_core to Version ^0.4.5
3042

3143
## 0.1.0+7
44+
3245
* Updated firebase_auth to Version ^0.16.0
3346

3447
## 0.1.0+6
48+
3549
* Downgraded Firebase version 0.15.3
3650

3751
## 0.1.0+5
52+
3853
* Use Firebase version 0.15.4
3954

4055
## 0.1.0+4
56+
4157
* Updated Firebase version
4258

4359
## 0.1.0+3
60+
4461
* Updated example
4562

4663
## 0.1.0+2
64+
4765
* Fix release builds on iOS
4866

4967
## 0.1.0+1
68+
5069
* Fix builds on iOS
5170

5271
## 0.1.0
72+
5373
* Initial release

firebase_auth_oauth/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ OAuth flows are performed by opening pop-up on top of the application to allow t
1515
dependencies:
1616
flutter:
1717
sdk: flutter
18-
firebase_auth: ^0.20.0+1
19-
firebase_core: ^0.7.0
20-
firebase_auth_oauth: ^0.2.4
18+
firebase_auth: ^1.0.0
19+
firebase_core: ^1.0.0
20+
firebase_auth_oauth: ^1.0.0
2121
```
2222

2323
- Then in your project just call

firebase_auth_oauth/android/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@ android {
4242
dependencies {
4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4444
implementation 'com.google.firebase:firebase-auth'
45+
implementation "androidx.browser:browser:1.3.0"
4546
implementation 'com.google.code.gson:gson:2.8.6'
4647
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="me.amryousef.apple.auth.firebase_apple_auth">
3+
4+
<queries>
5+
<intent>
6+
<action android:name="android.intent.action.VIEW" />
7+
<category android:name="android.intent.category.BROWSABLE" />
8+
<data android:scheme="https" />
9+
</intent>
10+
</queries>
311
</manifest>

firebase_auth_oauth/android/src/main/kotlin/me/amryousef/apple/auth/firebase_auth_oauth/FirebaseAuthOAuthPlugin.kt

+22-12
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,36 @@ import io.flutter.plugin.common.PluginRegistry.Registrar
1818

1919

2020
/** FirebaseAppleAuthPlugin */
21-
@Suppress("DEPRECATION")
2221
class FirebaseAuthOAuthPlugin : FlutterPlugin, ActivityAware, MethodCallHandler {
2322

2423
private var activity: Activity? = null
2524

2625
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
27-
val channel = MethodChannel(flutterPluginBinding.flutterEngine.dartExecutor, "me.amryousef.apple.auth/firebase_auth_oauth")
26+
val channel = MethodChannel(
27+
flutterPluginBinding.binaryMessenger,
28+
"me.amryousef.apple.auth/firebase_auth_oauth"
29+
)
2830
channel.setMethodCallHandler(this)
2931
}
3032

3133
companion object {
3234
private const val CREATE_USER_METHOD = "openSignInFlow"
3335
private const val LINK_USER_METHOD = "linkExistingUserWithCredentials"
3436

35-
@Suppress("unused")
37+
@Suppress("unused", "deprecation")
3638
@JvmStatic
3739
fun registerWith(registrar: Registrar) {
38-
val channel = MethodChannel(registrar.messenger(), "me.amryousef.apple.auth/firebase_auth_oauth")
39-
channel.setMethodCallHandler(FirebaseAuthOAuthPlugin().apply { activity = registrar.activity() })
40+
val channel =
41+
MethodChannel(registrar.messenger(), "me.amryousef.apple.auth/firebase_auth_oauth")
42+
channel.setMethodCallHandler(FirebaseAuthOAuthPlugin().apply {
43+
activity = registrar.activity()
44+
})
4045
}
4146
}
4247

4348
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
44-
val providerBuilder = call.argument<String>("provider")?.let { OAuthProvider.newBuilder(it) }
49+
val providerBuilder =
50+
call.argument<String>("provider")?.let { OAuthProvider.newBuilder(it) }
4551
if (providerBuilder == null) {
4652
FirebaseAuthOAuthPluginError
4753
.PluginError("Provider argument cannot be null")
@@ -62,7 +68,8 @@ class FirebaseAuthOAuthPlugin : FlutterPlugin, ActivityAware, MethodCallHandler
6268
providerBuilder.addCustomParameters(
6369
gson.fromJson<Map<String, String>>(
6470
it,
65-
object : TypeToken<Map<String, String>>() {}.type)
71+
object : TypeToken<Map<String, String>>() {}.type
72+
)
6673
)
6774
}
6875
val provider = providerBuilder.build()
@@ -77,7 +84,8 @@ class FirebaseAuthOAuthPlugin : FlutterPlugin, ActivityAware, MethodCallHandler
7784
FirebaseAuthOAuthPluginError
7885
.FirebaseAuthError(error)
7986
.toResult(result)
80-
} ?: auth.startActivityForSignInWithProvider(it, provider).addOnSuccessListener { authResult ->
87+
} ?: auth.startActivityForSignInWithProvider(it, provider)
88+
.addOnSuccessListener { authResult ->
8189
if (call.method == CREATE_USER_METHOD) {
8290
result.success("")
8391
return@addOnSuccessListener
@@ -91,17 +99,18 @@ class FirebaseAuthOAuthPlugin : FlutterPlugin, ActivityAware, MethodCallHandler
9199
user?.linkWithCredential(authResult.credential!!)
92100
}
93101
}.addOnFailureListener { error ->
94-
FirebaseAuthOAuthPluginError
95-
.FirebaseAuthError(error)
96-
.toResult(result)
97-
}
102+
FirebaseAuthOAuthPluginError
103+
.FirebaseAuthError(error)
104+
.toResult(result)
105+
}
98106
}
99107
}
100108

101109
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
102110
}
103111

104112
override fun onDetachedFromActivity() {
113+
activity = null
105114
}
106115

107116
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
@@ -113,5 +122,6 @@ class FirebaseAuthOAuthPlugin : FlutterPlugin, ActivityAware, MethodCallHandler
113122
}
114123

115124
override fun onDetachedFromActivityForConfigChanges() {
125+
activity = null
116126
}
117127
}

firebase_auth_oauth/example/android/app/src/main/AndroidManifest.xml

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@
77
FlutterApplication and put your custom class here. -->
88
<application
99
android:name="io.flutter.app.FlutterApplication"
10-
android:label="firebase_apple_auth_example"
11-
android:icon="@mipmap/ic_launcher">
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="firebase_apple_auth_example">
1212
<activity
1313
android:name=".MainActivity"
14-
android:launchMode="singleTop"
15-
android:theme="@style/LaunchTheme"
1614
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1715
android:hardwareAccelerated="true"
16+
android:launchMode="singleTop"
17+
android:theme="@style/LaunchTheme"
1818
android:windowSoftInputMode="adjustResize">
1919
<intent-filter>
20-
<action android:name="android.intent.action.MAIN"/>
21-
<category android:name="android.intent.category.LAUNCHER"/>
20+
<action android:name="android.intent.action.MAIN" />
21+
<category android:name="android.intent.category.LAUNCHER" />
2222
</intent-filter>
2323
</activity>
2424
<!-- Don't delete the meta-data below.
2525
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
2626
<meta-data
2727
android:name="flutterEmbedding"
2828
android:value="2" />
29+
2930
</application>
3031
</manifest>

firebase_auth_oauth/example/android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.50'
2+
ext.kotlin_version = '1.4.20'
33
repositories {
44
google()
5-
jcenter()
5+
mavenCentral()
66
}
77

88
dependencies {
@@ -15,7 +15,7 @@ buildscript {
1515
allprojects {
1616
repositories {
1717
google()
18-
jcenter()
18+
mavenCentral()
1919
}
2020
}
2121

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Sep 05 09:11:23 BST 2020
1+
#Sat Mar 06 11:26:02 GMT 2021
22
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https://services.gradle.org/distributions/gradle-6.8.2-bin.zip
34
distributionPath=wrapper/dists
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
6+
zipStoreBase=GRADLE_USER_HOME
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
23
#include "Generated.xcconfig"
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
23
#include "Generated.xcconfig"

firebase_auth_oauth/example/ios/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
platform :ios, '9.0'
2+
platform :ios, '10.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

0 commit comments

Comments
 (0)