-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: server - FCM refactor: app - compose feat: app - FCM
- Loading branch information
1 parent
ddc1e5d
commit 75fa65e
Showing
146 changed files
with
6,246 additions
and
3,229 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
|
||
**/xcuserdata | ||
**/dev.xcconfig | ||
**/real.xcconfig | ||
**/real.xcconfig | ||
**/*.podspec |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,12 +1,45 @@ | ||
import SwiftUI | ||
import FirebaseCore | ||
|
||
import Firebase | ||
import UserNotifications | ||
|
||
class AppDelegate: NSObject, UIApplicationDelegate { | ||
func application(_ application: UIApplication, | ||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | ||
FirebaseApp.configure() | ||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | ||
FirebaseApp.configure() | ||
|
||
initRemoteNotifications(application: application) | ||
initFirebaseMessaging() | ||
|
||
return true | ||
} | ||
|
||
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | ||
Messaging.messaging().apnsToken = deviceToken | ||
} | ||
|
||
|
||
func initRemoteNotifications(application: UIApplication) { | ||
UNUserNotificationCenter.current().delegate = self | ||
|
||
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] | ||
UNUserNotificationCenter.current().requestAuthorization( | ||
options: authOptions, | ||
completionHandler: { _, _ in } | ||
) | ||
|
||
application.registerForRemoteNotifications() | ||
} | ||
|
||
func initFirebaseMessaging() { | ||
Messaging.messaging().delegate = self | ||
} | ||
} | ||
|
||
extension AppDelegate: UNUserNotificationCenterDelegate { | ||
|
||
} | ||
|
||
return true | ||
} | ||
extension AppDelegate: MessagingDelegate { | ||
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { | ||
print("Firebase registration token: \(String(describing: fcmToken))") | ||
} | ||
} |
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,8 @@ | ||
<?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>aps-environment</key> | ||
<string>development</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
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
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
33 changes: 33 additions & 0 deletions
33
...src/commonMain/kotlin/io/github/taetae98coding/diary/core/diary/service/fcm/FCMService.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,33 @@ | ||
package io.github.taetae98coding.diary.core.diary.service.fcm | ||
|
||
import io.github.taetae98coding.diary.common.model.request.fcm.DeleteFCMRequest | ||
import io.github.taetae98coding.diary.common.model.request.fcm.UpsertFCMRequest | ||
import io.github.taetae98coding.diary.core.diary.service.DiaryServiceModule | ||
import io.github.taetae98coding.diary.core.diary.service.ext.getOrThrow | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.request.post | ||
import io.ktor.client.request.setBody | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.contentType | ||
import org.koin.core.annotation.Factory | ||
import org.koin.core.annotation.Named | ||
|
||
@Factory | ||
public class FCMService internal constructor( | ||
@Named(DiaryServiceModule.DIARY_CLIENT) | ||
private val client: HttpClient, | ||
) { | ||
public suspend fun upsert(token: String) { | ||
return client.post("/fcm/upsert") { | ||
contentType(ContentType.Application.Json) | ||
setBody(UpsertFCMRequest(token)) | ||
}.getOrThrow() | ||
} | ||
|
||
public suspend fun delete(token: String) { | ||
return client.post("/fcm/delete") { | ||
contentType(ContentType.Application.Json) | ||
setBody(DeleteFCMRequest(token)) | ||
}.getOrThrow() | ||
} | ||
} |
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
Oops, something went wrong.