-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
355 additions
and
25 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
app-ios-shared/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/shared/KmpHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.github.droidkaigi.confsched2023.shared | ||
|
||
import kotlinx.cinterop.BetaInteropApi | ||
import kotlinx.cinterop.ObjCProtocol | ||
import kotlinx.cinterop.getOriginalKotlinClass | ||
|
||
@OptIn(BetaInteropApi::class) | ||
fun KmpEntryPoint.get(objCProtocol: ObjCProtocol): Any { | ||
val kClazz = getOriginalKotlinClass(objCProtocol)!! | ||
return get(kClazz) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app-ios/App/DroidKaigi2023/DroidKaigi2023/GoogleService-Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CLIENT_ID</key> | ||
<string>1046519477136-gni68m3pq6059ivee422f6mfpp7h1c0h.apps.googleusercontent.com</string> | ||
<key>REVERSED_CLIENT_ID</key> | ||
<string>com.googleusercontent.apps.1046519477136-gni68m3pq6059ivee422f6mfpp7h1c0h</string> | ||
<key>ANDROID_CLIENT_ID</key> | ||
<string>1046519477136-8nv86645bl6a09hr0rqrr7qso3u9n16u.apps.googleusercontent.com</string> | ||
<key>API_KEY</key> | ||
<string>AIzaSyDl9v9XzP31jrauM1twqkNPi-m5J3B2nrM</string> | ||
<key>GCM_SENDER_ID</key> | ||
<string>1046519477136</string> | ||
<key>PLIST_VERSION</key> | ||
<string>1</string> | ||
<key>BUNDLE_ID</key> | ||
<string>io.github.droidkaigi.DroidKaigi2023</string> | ||
<key>PROJECT_ID</key> | ||
<string>ssot-api-staging</string> | ||
<key>STORAGE_BUCKET</key> | ||
<string>ssot-api-staging.appspot.com</string> | ||
<key>IS_ADS_ENABLED</key> | ||
<false/> | ||
<key>IS_ANALYTICS_ENABLED</key> | ||
<false/> | ||
<key>IS_APPINVITE_ENABLED</key> | ||
<true/> | ||
<key>IS_GCM_ENABLED</key> | ||
<true/> | ||
<key>IS_SIGNIN_ENABLED</key> | ||
<true/> | ||
<key>GOOGLE_APP_ID</key> | ||
<string>1:1046519477136:ios:a9459b469c5a1984a8f915</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import FirebaseAuth | ||
import shared | ||
|
||
public class AuthenticatorImpl: Authenticator { | ||
public init() {} | ||
public func currentUser() async throws -> shared.User? { | ||
let currentUser = Auth.auth().currentUser | ||
let idToken = try await currentUser?.getIDToken() | ||
|
||
return idToken.map(User.init(idToken:)) | ||
} | ||
|
||
public func signInAnonymously() async throws -> shared.User? { | ||
let result = try await Auth.auth().signInAnonymously() | ||
let idToken = try await result.user.getIDToken() | ||
return User(idToken: idToken) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Auth | ||
import Firebase | ||
import RemoteConfig | ||
import shared | ||
|
||
struct Container { | ||
static let shared: Container = .init() | ||
|
||
private let entryPoint: KmpEntryPoint | ||
private init() { | ||
FirebaseApp.configure() | ||
entryPoint = .init() | ||
entryPoint.doInit( | ||
remoteConfigApi: RemoteConfigApiImpl(), | ||
authenticator: AuthenticatorImpl() | ||
) | ||
} | ||
|
||
func get<TypeProtocol, ReturnType>(type: TypeProtocol) -> ReturnType where TypeProtocol: Protocol { | ||
guard let object = entryPoint.get(objCProtocol: type) as? ReturnType else { | ||
fatalError("Not found instance for \(type)") | ||
} | ||
return object | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app-ios/Modules/Sources/KMPContainer/Exetnsions/Kotlinx_coroutines_coreFlow.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import shared | ||
|
||
class FlowCollector<T>: Kotlinx_coroutines_coreFlowCollector { | ||
let callback: (T) -> Void | ||
|
||
init(callback: @escaping (T) -> Void) { | ||
self.callback = callback | ||
} | ||
|
||
func emit(value: Any?, completionHandler: @escaping (Error?) -> Void) { | ||
if let value = value as? T { | ||
callback(value) | ||
} | ||
completionHandler(nil) | ||
} | ||
} | ||
|
||
public extension Kotlinx_coroutines_coreFlow { | ||
// Note: Calling Kotlin suspend functions from Swift/Objective-C is currently supported only on main thread | ||
@MainActor | ||
func stream<T>() -> AsyncThrowingStream<T, Error> { | ||
return AsyncThrowingStream { [weak self] continuation in | ||
self?.collect(collector: FlowCollector<T>(callback: { value in | ||
continuation.yield(value) | ||
}), completionHandler: { error in | ||
if let error = error { | ||
continuation.finish(throwing: error) | ||
} else { | ||
continuation.finish() | ||
} | ||
}) | ||
} | ||
} | ||
} |
Oops, something went wrong.