[firebase_auth] Add macOS support#1705
Conversation
f5b086b to
942bf72
Compare
05dd082 to
948382b
Compare
9653c6f to
bec507a
Compare
|
Great work! Is here any process? |
|
I shared the code between iOS and macOS by hiding unsupported stuff. Here is a diff for convenience as git will not show it due to the symlink: --- FLTFirebaseAuthPlugin-old.m 2020-02-16 12:54:25.000000000 +0100
+++ FLTFirebaseAuthPlugin.m 2020-02-16 12:55:36.000000000 +0100
@@ -1,6 +1,7 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <TargetConditionals.h>
#import "FLTFirebaseAuthPlugin.h"
#import "UserAgent.h"
@@ -43,7 +44,9 @@
FLTFirebaseAuthPlugin *instance = [[FLTFirebaseAuthPlugin alloc] init];
instance.channel = channel;
instance.authStateChangeListeners = [[NSMutableDictionary alloc] init];
+#if TARGET_OS_IPHONE
[registrar addApplicationDelegate:instance];
+#endif
[registrar addMethodCallDelegate:instance channel:channel];
SEL sel = NSSelectorFromString(@"registerLibrary:withVersion:");
@@ -69,6 +72,7 @@
return [FIRAuth authWithApp:[FIRApp appNamed:appName]];
}
+#if TARGET_OS_IPHONE
- (bool)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)notification
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
@@ -87,6 +91,7 @@
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
return [[FIRAuth auth] canHandleURL:url];
}
+#endif
// TODO(jackson): We should use the renamed versions of the following methods
// when they are available in the Firebase SDK that this plugin is dependent on.
@@ -265,7 +270,9 @@
forObject:nil
error:error];
}];
- } else if ([@"updatePhoneNumberCredential" isEqualToString:call.method]) {
+ }
+#if TARGET_OS_IPHONE
+ else if ([@"updatePhoneNumberCredential" isEqualToString:call.method]) {
FIRPhoneAuthCredential *credential =
(FIRPhoneAuthCredential *)[self getCredential:call.arguments];
[[self getAuth:call.arguments].currentUser
@@ -273,7 +280,9 @@
completion:^(NSError *_Nullable error) {
[self sendResult:result forObject:nil error:error];
}];
- } else if ([@"updatePassword" isEqualToString:call.method]) {
+ }
+#endif
+ else if ([@"updatePassword" isEqualToString:call.method]) {
NSString *password = call.arguments[@"password"];
[[self getAuth:call.arguments].currentUser updatePassword:password
completion:^(NSError *error) {
@@ -332,7 +341,9 @@
identifier.intValue]
details:nil]);
}
- } else if ([@"verifyPhoneNumber" isEqualToString:call.method]) {
+ }
+#if TARGET_OS_IPHONE
+ else if ([@"verifyPhoneNumber" isEqualToString:call.method]) {
NSString *phoneNumber = call.arguments[@"phoneNumber"];
NSNumber *handle = call.arguments[@"handle"];
[[FIRPhoneAuthProvider provider]
@@ -367,7 +378,9 @@
forAuthDataResult:authResult
error:error];
}];
- } else if ([@"setLanguageCode" isEqualToString:call.method]) {
+ }
+#endif
+ else if ([@"setLanguageCode" isEqualToString:call.method]) {
NSString *language = call.arguments[@"language"];
[[self getAuth:call.arguments] setLanguageCode:language];
[self sendResult:result forObject:nil error:nil];
@@ -487,13 +500,17 @@
} else if ([FIRGitHubAuthProviderID isEqualToString:provider]) {
NSString *token = data[@"token"];
credential = [FIRGitHubAuthProvider credentialWithToken:token];
- } else if ([FIRPhoneAuthProviderID isEqualToString:provider]) {
+ }
+#if TARGET_OS_IPHONE
+ else if ([FIRPhoneAuthProviderID isEqualToString:provider]) {
NSString *verificationId = data[@"verificationId"];
NSString *smsCode = data[@"smsCode"];
credential = [[FIRPhoneAuthProvider providerWithAuth:[self getAuth:arguments]]
credentialWithVerificationID:verificationId
verificationCode:smsCode];
- } else if ([provider length] != 0 && data[@"idToken"] != (id)[NSNull null] &&
+ }
+#endif
+ else if ([provider length] != 0 && data[@"idToken"] != (id)[NSNull null] &&
(data[@"accessToken"] != (id)[NSNull null] ||
data[@"rawNonce"] != (id)[NSNull null])) {
NSString *idToken = data[@"idToken"];
@AndroidNils this is almost finished and if you want to play with it today you can use it with: dependency_overrides:
firebase_auth:
git:
url: https://github.com/cbenhagen/flutterfire
path: packages/firebase_auth/firebase_auth
ref: firebase_auth_macos |
4bcbf73 to
b23b63b
Compare
c4729b0 to
eff12e2
Compare
Thank you! I tested it, but I got this error: My Flutter Version is |
|
Maybe You can try to go into the macos directory and run |
Thanks for the quick response! I tried it, but it didn't work. But I tested it in a new flutter project with the same Firebase Project, etc. and there it worked. So it issue is related to our flutter project. I tried also to move the macOS folder from the working flutter project to our project. But this changed nothing. Some issue. |
|
@AndroidNils can you post the output of |
packages/firebase_auth/firebase_auth/darwin/Classes/FLTFirebaseAuthPlugin.m
Show resolved
Hide resolved
3bef0a5 to
efe4dca
Compare
Here is the log: https://hastebin.com/fopeqovoqi.sql - I hope it helps! |
|
@AndroidNils you are indeed missing |
|
@AndroidNils can you try to:
|
|
@AndroidNils the commands I just sent you most likely will not work. I hope someone has an idea how to properly handle this. Meanwhile you can just copy the |
Yes, with this command it works. |
Description
Add macOS support.
Related Issues
#1653
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?