Skip to content

Commit

Permalink
Merge pull request #1038 from 0x1-company/facebook-ios-sdk
Browse files Browse the repository at this point in the history
feat: facebook ios sdk
  • Loading branch information
tomokisun authored Dec 2, 2023
2 parents a332777 + 7540510 commit 0a3e0f9
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 15 deletions.
4 changes: 3 additions & 1 deletion App/Multiplatform/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
store.send(.appDelegate(.didFinishLaunching))
store.send(.appDelegate(.didFinishLaunching(application, launchOptions)))
return true
}

Expand Down Expand Up @@ -89,6 +89,8 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
store.send(.appDelegate(.open(app, url, options)))

if firebaseAuth.canHandle(url) {
return true
}
Expand Down
19 changes: 19 additions & 0 deletions App/Multiplatform/Development/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<string>1.12.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>777631217454373</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
Expand Down Expand Up @@ -110,5 +118,16 @@
<false/>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>FacebookAppID</key>
<string>777631217454373</string>
<key>FacebookClientToken</key>
<string>b380f70d7d502438758535da9c90602d</string>
<key>FacebookDisplayName</key>
<string>God</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions App/Multiplatform/Production/App.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<array>
<string>applinks:godjp.page.link</string>
</array>
<key>keychain-access-groups</key>
<array/>
</dict>
</plist>
19 changes: 19 additions & 0 deletions App/Multiplatform/Production/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<string>1.12.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>777631217454373</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
Expand Down Expand Up @@ -122,5 +130,16 @@
<string>jp.godapp.ios.god_mode.default</string>
<key>REVEAL_POLL_ID</key>
<string>jp.godapp.ios.reveal_poll</string>
<key>FacebookAppID</key>
<string>777631217454373</string>
<key>FacebookClientToken</key>
<string>b380f70d7d502438758535da9c90602d</string>
<key>FacebookDisplayName</key>
<string>God</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions App/Multiplatform/Staging/App.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<array>
<string>applinks:godstaging.page.link</string>
</array>
<key>keychain-access-groups</key>
<array/>
</dict>
</plist>
39 changes: 27 additions & 12 deletions App/Multiplatform/Staging/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<string>1.12.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>777631217454373</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
Expand All @@ -34,21 +42,30 @@
<string>jp.godapp.ios.staging</string>
</array>
</dict>
<dict/>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>FIREBASE_ANALYTICS_COLLECTION_ENABLED</key>
<true/>
<key>FacebookAppID</key>
<string>777631217454373</string>
<key>FacebookClientToken</key>
<string>b380f70d7d502438758535da9c90602d</string>
<key>FacebookDisplayName</key>
<string>God</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>FirebaseAutomaticScreenReportingEnabled</key>
<false/>
<key>GOD_MODE_ID</key>
<string>jp.godapp.ios.staging.god_mode.default</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
<string>instagram-stories</string>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
Expand All @@ -58,6 +75,13 @@
<string>Your contacts are used to find friends and uploaded to a server.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Your Photo Library are used to select profile picture.</string>
<key>REVEAL_POLL_ID</key>
<string>jp.godapp.ios.staging.reveal_poll</string>
<key>UIAppFonts</key>
<array>
<string>MPLUSRounded1c-Bold.ttf</string>
<string>MPLUSRounded1c-Regular.ttf</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down Expand Up @@ -85,7 +109,7 @@
<key>UIApplicationShortcutItemSubtitle</key>
<string>Give it a secound chance!</string>
<key>UIApplicationShortcutItemTitle</key>
<string>🥺 Don&apos;t remove the God App!</string>
<string>🥺 Don't remove the God App!</string>
<key>UIApplicationShortcutItemType</key>
<string>/</string>
</dict>
Expand Down Expand Up @@ -119,18 +143,9 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIAppFonts</key>
<array>
<string>MPLUSRounded1c-Bold.ttf</string>
<string>MPLUSRounded1c-Regular.ttf</string>
</array>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>endpointURL</key>
<string>https://god-server-dip5kutcuq-an.a.run.app/graphql</string>
<key>GOD_MODE_ID</key>
<string>jp.godapp.ios.staging.god_mode.default</string>
<key>REVEAL_POLL_ID</key>
<string>jp.godapp.ios.staging.reveal_poll</string>
</dict>
</plist>
9 changes: 9 additions & 0 deletions God.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
"version" : "1.0.0"
}
},
{
"identity" : "facebook-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/facebook/facebook-ios-sdk",
"state" : {
"revision" : "ebfaa5eb867c9ad3e0b54ef8b03883f024cfc18a",
"version" : "16.2.1"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
Expand Down
7 changes: 7 additions & 0 deletions Packages/DependencyPackage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let package = Package(
.library(name: "AsyncValue", targets: ["AsyncValue"]),
.library(name: "Constants", targets: ["Constants"]),
.library(name: "DeleteAccountReasonClient", targets: ["DeleteAccountReasonClient"]),
.library(name: "FacebookClient", targets: ["FacebookClient"]),
.library(name: "FirebaseAuthClient", targets: ["FirebaseAuthClient"]),
.library(name: "FirebaseCoreClient", targets: ["FirebaseCoreClient"]),
.library(name: "FirebaseDynamicLinkClient", targets: ["FirebaseDynamicLinkClient"]),
Expand All @@ -42,6 +43,7 @@ let package = Package(
.package(url: "https://github.com/marmelroy/PhoneNumberKit", from: "3.7.5"),
.package(url: "https://github.com/apollographql/apollo-ios", from: "1.6.1"),
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.1.2"),
.package(url: "https://github.com/facebook/facebook-ios-sdk", from: "16.2.1"),
],
targets: [
.target(name: "AnalyticsClient", dependencies: [
Expand All @@ -64,6 +66,11 @@ let package = Package(
.product(name: "FirebaseFirestoreSwift", package: "firebase-ios-sdk"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]),
.target(name: "FacebookClient", dependencies: [
.product(name: "FacebookCore", package: "facebook-ios-sdk"),
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
]),
.target(name: "FirebaseAuthClient", dependencies: [
.product(name: "FirebaseAuth", package: "firebase-ios-sdk"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
Expand Down
21 changes: 21 additions & 0 deletions Packages/DependencyPackage/Sources/FacebookClient/Client.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Dependencies
import DependenciesMacros
import FacebookCore

@DependencyClient
public struct FacebookClient: Sendable {
public var didFinishLaunchingWithOptions: @Sendable (UIApplication, [UIApplication.LaunchOptionsKey: Any]?) -> Void
public var open: @Sendable (UIApplication, URL, String?, Any?) -> Void
}

extension FacebookClient: TestDependencyKey {
public static let testValue = Self()
public static let previewValue = Self()
}

public extension DependencyValues {
var facebook: FacebookClient {
get { self[FacebookClient.self] }
set { self[FacebookClient.self] = newValue }
}
}
13 changes: 13 additions & 0 deletions Packages/DependencyPackage/Sources/FacebookClient/LiveKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Dependencies
import FacebookCore

extension FacebookClient: DependencyKey {
public static let liveValue = Self(
didFinishLaunchingWithOptions: { application, didFinishLaunchingWithOptions in
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: didFinishLaunchingWithOptions)
},
open: { application, open, sourceApplication, annotation in
ApplicationDelegate.shared.application(application, open: open, sourceApplication: sourceApplication, annotation: annotation)
}
)
}
1 change: 1 addition & 0 deletions Packages/GodPackage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ let package = Package(
"MaintenanceFeature",
.product(name: "TcaHelpers", package: "DependencyPackage"),
.product(name: "StoreKitClient", package: "CupertinoPackage"),
.product(name: "FacebookClient", package: "DependencyPackage"),
.product(name: "FirestoreClient", package: "DependencyPackage"),
.product(name: "UserSettingsClient", package: "DependencyPackage"),
.product(name: "FirebaseCoreClient", package: "DependencyPackage"),
Expand Down
18 changes: 16 additions & 2 deletions Packages/GodPackage/Sources/AppFeature/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import GodClient
import UIKit
import UserDefaultsClient
import UserNotificationClient
import FacebookClient

@Reducer
public struct AppDelegateLogic {
public struct State: Equatable {}
public enum Action {
case didFinishLaunching
case didFinishLaunching(UIApplication, [UIApplication.LaunchOptionsKey: Any]?)
case open(UIApplication, URL, [UIApplication.OpenURLOptionsKey: Any])
case dynamicLink(URL?)
case didReceiveRemoteNotification([AnyHashable: Any])
case didRegisterForRemoteNotifications(TaskResult<Data>)
Expand All @@ -37,6 +39,7 @@ public struct AppDelegateLogic {
}
}

@Dependency(\.facebook) var facebook
@Dependency(\.analytics) var analytics
@Dependency(\.userDefaults) var userDefaults
@Dependency(\.firebaseCore) var firebaseCore
Expand All @@ -48,8 +51,9 @@ public struct AppDelegateLogic {

public func reduce(into state: inout State, action: Action) -> Effect<Action> {
switch action {
case .didFinishLaunching:
case let .didFinishLaunching(application, launchOptions):
firebaseCore.configure()
facebook.didFinishLaunchingWithOptions(application, launchOptions)
return .run { @MainActor send in
await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
Expand All @@ -67,6 +71,16 @@ public struct AppDelegateLogic {
}
}
}

case let .open(application, url, options):
facebook.open(
application,
url,
options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
options[UIApplication.OpenURLOptionsKey.annotation]
)
return .none

case let .didReceiveRemoteNotification(userInfo):
guard let badge = userInfo["badge"] as? String else { return .none }
guard let badgeCount = Int(badge) else { return .none }
Expand Down

0 comments on commit 0a3e0f9

Please sign in to comment.