Skip to content

Commit

Permalink
Update facebook and firebase samples (#25)
Browse files Browse the repository at this point in the history
Adds simple Firebase.Auth demo.
Fixes facebook android dependencies.
  • Loading branch information
pjcollins authored Jun 18, 2024
1 parent 6be7747 commit 5fcae27
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Install prerequisites:
- [Android SDK](https://developer.android.com/tools)
- [Android Studio](https://developer.android.com/studio)
- [Objective-Sharpie](https://aka.ms/objective-sharpie)
- [Xamarin.iOS](https://download.visualstudio.microsoft.com/download/pr/ceb0ea3f-4db8-46b4-8dc3-8049d27c0107/3960868aa9b1946a6c77668c3f3334ee/xamarin.ios-16.4.0.23.pkg)
- [Visual Studio](https://visualstudio.microsoft.com/downloads/) or [Visual Studio Code](https://code.visualstudio.com/download)
- [Xcode](https://developer.apple.com/xcode/)
- [Xcode Command Line Tools](https://developer.apple.com/download/all/?q=command%20line%20tools) (```xcode-select --install```)
Expand Down
4 changes: 4 additions & 0 deletions facebook/sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
<ItemGroup Condition="$(TargetFramework.Contains('android'))">
<ProjectReference Include="..\android\Facebook.Android.Binding\Facebook.Android.Binding.csproj" />
<!-- Include core facebook dependencies. Starting in .NET 9 these can potentially be replaced with @(AndroidMavenPackage) -->
<AndroidLibrary Include="..\android\native\mauifacebook\build\outputs\deps\facebook-android-sdk*.aar">
<Bind>false</Bind>
<Visible>false</Visible>
</AndroidLibrary>
<AndroidLibrary Include="..\android\native\mauifacebook\build\outputs\deps\facebook-common*.aar">
<Bind>false</Bind>
<Visible>false</Visible>
Expand Down
85 changes: 85 additions & 0 deletions firebase/macios/Firebase.MaciOS.Binding/ApiDefinitions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable enable
using System;
using Foundation;
using ObjCRuntime;

namespace Firebase
{
Expand Down Expand Up @@ -55,6 +56,90 @@ interface MauiFIRApp
void Configure (string googleAppId, string gcmSenderId);
}

// @interface MauiFIRAuth : NSObject
[BaseType (typeof(NSObject))]
interface MauiFIRAuth
{
// -(void)setAuthStateListener:(void (^ _Nonnull)(MauiFIRAuthUser * _Nullable))callback;
[Static]
[Export ("setAuthStateListener:")]
[Async]
void SetAuthStateListener (Action<MauiFIRAuthUser> callback);

// -(void)createUser:(NSString * _Nonnull)email password:(NSString * _Nonnull)password callback:(void (^ _Nonnull)(MauiFIRAuthResult * _Nullable, NSError * _Nullable))callback;
[Static]
[Export ("createUser:password:callback:")]
[Async]
void CreateUser (string email, string password, Action<MauiFIRAuthResult, NSError> callback);

// -(void)signIn:(NSString * _Nonnull)email password:(NSString * _Nonnull)password callback:(void (^ _Nonnull)(MauiFIRAuthResult * _Nullable, NSError * _Nullable))callback;
[Static]
[Export ("signIn:password:callback:")]
[Async]
void SignIn (string email, string password, Action<MauiFIRAuthResult, NSError> callback);

// -(NSError * _Nullable)signOut __attribute__((warn_unused_result("")));
[Static]
[Export ("signOut")]
NSError SignOut();
}

// @interface MauiFIRAuthResult : NSObject
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface MauiFIRAuthResult
{
// @property (readonly, nonatomic, strong) MauiFIRAuthUser * _Nullable user;
[NullAllowed, Export ("user", ArgumentSemantic.Strong)]
MauiFIRAuthUser User { get; }
}

// @interface MauiFIRAuthUser : NSObject
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface MauiFIRAuthUser
{
// @property (readonly, copy, nonatomic) NSString * _Nullable uid;
[NullAllowed, Export ("uid")]
string Uid { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable displayName;
[NullAllowed, Export ("displayName")]
string DisplayName { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable email;
[NullAllowed, Export ("email")]
string Email { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable refreshToken;
[NullAllowed, Export ("refreshToken")]
string RefreshToken { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable providerId;
[NullAllowed, Export ("providerId")]
string ProviderId { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable tenantId;
[NullAllowed, Export ("tenantId")]
string TenantId { get; }

// @property (readonly, copy, nonatomic) NSString * _Nullable phoneNumber;
[NullAllowed, Export ("phoneNumber")]
string PhoneNumber { get; }

// @property (readonly, nonatomic) BOOL isAnonymous;
[Export ("isAnonymous")]
bool IsAnonymous { get; }

// @property (readonly, nonatomic) BOOL isEmailVerified;
[Export ("isEmailVerified")]
bool IsEmailVerified { get; }

// @property (readonly, copy, nonatomic) NSURL * _Nullable photoUrl;
[NullAllowed, Export ("photoUrl", ArgumentSemantic.Copy)]
NSUrl PhotoUrl { get; }
}

// @interface MauiFIRMessaging : NSObject
[BaseType (typeof(NSObject))]
interface MauiFIRMessaging
Expand Down
12 changes: 8 additions & 4 deletions firebase/macios/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Firebase Slim Binding
This folder contains a slim binding for the Firebase SDK which demonstrates simple [Analytics][0] and [Messaging][1] usage.
This folder contains a slim binding for the Firebase SDK which demonstrates simple [Analytics][0], [Auth][1], and [Messaging][2] usage.

### Build and Run
```shell
Expand All @@ -9,12 +9,16 @@ This folder contains a slim binding for the Firebase SDK which demonstrates simp
### Configure
The included sample requires some modification to fully function. You will need to log in to
a Firebase developer account and configure an app to interface with this sample.
For more details, reference the [Get Started (iOS)][2] page.
For more details, reference the [Get Started (iOS)][3] page.

1. Download your `GoogleService-Info.plist` and replace `Platforms/iOS/GoogleService-Info.plist` with it.
2. Change the `<ApplicationId>` value in `Sample.csproj` to your Firebase iOS app identifier.

To deploy this sample to a physical iOS device you will need to open `native/MauiFirebase.xcodeproj`
in Xcode and configure the signing team/settings in Targets -> MauiFirebase -> Signing & Capabilities.
A provisioning profile that supports Apple Notification Service (APNs) must also be configured and installed.

[0]: https://firebase.google.com/docs/analytics/get-started?platform=ios
[1]: https://firebase.google.com/docs/cloud-messaging/ios/client
[2]: https://firebase.google.com/docs/ios/setup
[1]: https://firebase.google.com/docs/auth/ios/start
[2]: https://firebase.google.com/docs/cloud-messaging/ios/client
[3]: https://firebase.google.com/docs/ios/setup
20 changes: 18 additions & 2 deletions firebase/macios/native/MauiFirebase.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
D051A4C32BD33D9100EC7F28 /* MauiFIRApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D051A4C22BD33D9100EC7F28 /* MauiFIRApp.swift */; };
D051A4C52BD33DB100EC7F28 /* MauiFIRMessaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = D051A4C42BD33DB100EC7F28 /* MauiFIRMessaging.swift */; };
D051A4C72BD33DBB00EC7F28 /* MauiFIRAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = D051A4C62BD33DBB00EC7F28 /* MauiFIRAnalytics.swift */; };
D0A597A92C22007900C52635 /* MauiFIRAuth.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0A597A82C22007900C52635 /* MauiFIRAuth.swift */; };
D0A597AB2C2200A800C52635 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = D0A597AA2C2200A800C52635 /* FirebaseAuth */; };
D0BECB2A2BD833BA00CDDD0A /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = D0BECB292BD833BA00CDDD0A /* FirebaseAnalytics */; };
D0BECB2C2BD833BA00CDDD0A /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = D0BECB2B2BD833BA00CDDD0A /* FirebaseMessaging */; };
D0BECB2E2BD8381100CDDD0A /* FirebaseInstallations in Frameworks */ = {isa = PBXBuildFile; productRef = D0BECB2D2BD8381100CDDD0A /* FirebaseInstallations */; };
Expand All @@ -22,6 +24,7 @@
D051A4C22BD33D9100EC7F28 /* MauiFIRApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MauiFIRApp.swift; sourceTree = "<group>"; };
D051A4C42BD33DB100EC7F28 /* MauiFIRMessaging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MauiFIRMessaging.swift; sourceTree = "<group>"; };
D051A4C62BD33DBB00EC7F28 /* MauiFIRAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MauiFIRAnalytics.swift; sourceTree = "<group>"; };
D0A597A82C22007900C52635 /* MauiFIRAuth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MauiFIRAuth.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -32,6 +35,7 @@
D0BECB2E2BD8381100CDDD0A /* FirebaseInstallations in Frameworks */,
D0BECB2C2BD833BA00CDDD0A /* FirebaseMessaging in Frameworks */,
D0BECB2A2BD833BA00CDDD0A /* FirebaseAnalytics in Frameworks */,
D0A597AB2C2200A800C52635 /* FirebaseAuth in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -62,6 +66,7 @@
D051A4C22BD33D9100EC7F28 /* MauiFIRApp.swift */,
D051A4C42BD33DB100EC7F28 /* MauiFIRMessaging.swift */,
D051A4C62BD33DBB00EC7F28 /* MauiFIRAnalytics.swift */,
D0A597A82C22007900C52635 /* MauiFIRAuth.swift */,
);
path = MauiFirebase;
sourceTree = "<group>";
Expand Down Expand Up @@ -105,6 +110,7 @@
D0BECB292BD833BA00CDDD0A /* FirebaseAnalytics */,
D0BECB2B2BD833BA00CDDD0A /* FirebaseMessaging */,
D0BECB2D2BD8381100CDDD0A /* FirebaseInstallations */,
D0A597AA2C2200A800C52635 /* FirebaseAuth */,
);
productName = MauiFirebase;
productReference = D051A4B82BD33D4600EC7F28 /* MauiFirebase.framework */;
Expand Down Expand Up @@ -164,6 +170,7 @@
D051A4C72BD33DBB00EC7F28 /* MauiFIRAnalytics.swift in Sources */,
D051A4C52BD33DB100EC7F28 /* MauiFIRMessaging.swift in Sources */,
D051A4C32BD33D9100EC7F28 /* MauiFIRApp.swift in Sources */,
D0A597A92C22007900C52635 /* MauiFIRAuth.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -302,17 +309,19 @@
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -341,17 +350,19 @@
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -409,6 +420,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
D0A597AA2C2200A800C52635 /* FirebaseAuth */ = {
isa = XCSwiftPackageProductDependency;
package = D0BECB282BD833BA00CDDD0A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseAuth;
};
D0BECB292BD833BA00CDDD0A /* FirebaseAnalytics */ = {
isa = XCSwiftPackageProductDependency;
package = D0BECB282BD833BA00CDDD0A /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
Expand Down
Loading

0 comments on commit 5fcae27

Please sign in to comment.