Skip to content

Commit

Permalink
Feat: 알림 리스트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
iosdevSW committed Aug 23, 2023
1 parent 065eb45 commit 4e75863
Show file tree
Hide file tree
Showing 44 changed files with 1,074 additions and 89 deletions.
111 changes: 104 additions & 7 deletions FitHub.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "bfc0b6f81adc06ce5121eb23f628473638d67c5c",
"version" : "1.2022062300.0"
}
},
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
Expand All @@ -9,6 +18,69 @@
"version" : "5.7.1"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "2bfe6abe1014aafe5cf28401708f7d39f9926a76",
"version" : "10.14.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "03b9beee1a61f62d32c521e172e192a1663a5e8b",
"version" : "10.13.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "aae45a320fd0d11811820335b1eabc8753902a40",
"version" : "9.2.5"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "c38ce365d77b04a9a300c31061c5227589e5597b",
"version" : "7.11.5"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "f1b366129d1125be7db83247e003fc333104b569",
"version" : "1.50.2"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd",
"version" : "3.1.1"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
"version" : "100.0.0"
}
},
{
"identity" : "kakao-ios-sdk",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -36,6 +108,24 @@
"version" : "7.8.1"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
"version" : "1.22.2"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
"version" : "2.30909.0"
}
},
{
"identity" : "ohhttpstubs",
"kind" : "remoteSourceControl",
Expand All @@ -45,6 +135,15 @@
"version" : "9.1.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e",
"version" : "2.3.1"
}
},
{
"identity" : "rxalamofire",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -99,6 +198,15 @@
"version" : "5.6.0"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "ce20dc083ee485524b802669890291c0d8090170",
"version" : "1.22.1"
}
},
{
"identity" : "then",
"kind" : "remoteSourceControl",
Expand Down
4 changes: 4 additions & 0 deletions FitHub.xcodeproj/xcshareddata/xcschemes/FitHub.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
ReferencedContainer = "container:FitHub.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<LocationScenarioReference
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
referenceType = "1">
</LocationScenarioReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
58 changes: 57 additions & 1 deletion FitHub/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import UIKit
import KakaoSDKCommon
import FirebaseCore
import Firebase

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -15,6 +17,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
guard let appKey = Bundle.main.object(forInfoDictionaryKey: "NativeAppKey") as? String else { return true }
KakaoSDK.initSDK(appKey: appKey)
FirebaseApp.configure()

self.registerForPushNotifications()
UNUserNotificationCenter.current().delegate = self
Messaging.messaging().delegate = self

return true
}
Expand All @@ -32,7 +39,56 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

//MARK: - RemotePushNotification
func registerForPushNotifications() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
print("Permission granted: \(granted)")
self.getNotificationSettings()
}
}

func getNotificationSettings() {
UNUserNotificationCenter.current().getNotificationSettings { settings in
print("Notification settings: \(settings)")
guard settings.authorizationStatus == .authorized else { return }
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("디바이스 토큰 정상 발급 완료")
Messaging.messaging().apnsToken = deviceToken
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register(deviceToken): \(error)")
}
}


extension AppDelegate: UNUserNotificationCenterDelegate {
// 포그라운드에서 받았을 때
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let content = notification.request.content

print("title: \(content.title)")
print("body: \(content.body)")
completionHandler([.badge , .banner, .sound])
}
// 백그라운드에서 받았을 때
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let content = response.notification.request.content
print("title: \(content.title)")
print("body: \(content.body)")
}
}

extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
guard let fcmToken else { return }
print("fcmToken 정상 발급 : \(fcmToken)")
UserDefaults.standard.set(fcmToken, forKey: "fcmToken")
}
}
16 changes: 11 additions & 5 deletions FitHub/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,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>NativeAppKey</key>
<string>$(NATIVE_APP_KEY)</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string>
<key>BaseURL</key>
<string>$(BASE_URL)</string>
<key>CFBundleURLTypes</key>
Expand All @@ -19,6 +19,13 @@
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
</array>
<key>NativeAppKey</key>
<string>$(NATIVE_APP_KEY)</string>
<key>UIAppFonts</key>
<array>
<string>Pretendard-SemiBold.otf</string>
Expand All @@ -42,10 +49,9 @@
</array>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<key>UIBackgroundModes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
<string>remote-notification</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Property [email protected]",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Property [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Property [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 0 additions & 34 deletions FitHub/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,39 +70,5 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
}
}

func setTapbar() -> UITabBarController {
let tabBarController = UITabBarController()
tabBarController.tabBar.backgroundColor = .bgDefault
tabBarController.selectedIndex = 1
tabBarController.tabBar.unselectedItemTintColor = .iconDisabled
tabBarController.tabBar.tintColor = .white

let homeUsecase = HomeUseCase(repository: HomeRepository(homeService: HomeService(),
authService: UserService()))
let homeVC = UINavigationController(rootViewController: HomeViewController(HomeViewModel(usecase: homeUsecase)))
homeVC.tabBarItem.image = UIImage(named: "HomeIcon")
homeVC.tabBarItem.title = ""

let communityVCUsecase = CommunityUseCase(CommunityRepository(UserService(),
certificationService: CertificationService(),
articleService: ArticleService()))
let communityVC = UINavigationController(rootViewController: CommunityViewController(CommunityViewModel(communityVCUsecase)))
communityVC.tabBarItem.image = UIImage(named: "CommunityIcon")
communityVC.tabBarItem.title = "커뮤니티"

let lookUpVC = UINavigationController(rootViewController: LookUpViewController())
lookUpVC.tabBarItem.image = UIImage(named: "LookUpIcon")
lookUpVC.tabBarItem.title = "둘러보기"

let myPageUsecase = MyPageUseCase(mypageRepository: MyPageRepository(service: UserService()))
let myPageVC = UINavigationController(rootViewController: MyPageViewController(viewModel: MyPageViewModel(usecase: myPageUsecase)))
myPageVC.tabBarItem.image = UIImage(named: "MyPageIcon")
myPageVC.tabBarItem.title = "마이핏허브"

tabBarController.viewControllers = [homeVC, communityVC, lookUpVC, myPageVC]

return tabBarController
}
}

8 changes: 6 additions & 2 deletions FitHub/Common/Extension/UIViewController+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ extension UIViewController {

let communityVCUsecase = CommunityUseCase(CommunityRepository(UserService(),
certificationService: CertificationService(),
articleService: ArticleService()))
articleService: ArticleService()),
homeRepo: HomeRepository(homeService: HomeService(),
authService: UserService()))
let communityVC = UINavigationController(rootViewController: CommunityViewController(CommunityViewModel(communityVCUsecase)))
communityVC.tabBarItem.image = UIImage(named: "CommunityIcon")
communityVC.tabBarItem.title = "커뮤니티"
Expand All @@ -62,7 +64,9 @@ extension UIViewController {
lookUpVC.tabBarItem.image = UIImage(named: "LookUpIcon")
lookUpVC.tabBarItem.title = "둘러보기"

let myPageUsecase = MyPageUseCase(mypageRepository: MyPageRepository(service: UserService()))
let myPageUsecase = MyPageUseCase(mypageRepository: MyPageRepository(service: UserService()),
homeRepository: HomeRepository(homeService: HomeService(),
authService: UserService()))
let myPageVC = UINavigationController(rootViewController: MyPageViewController(viewModel: MyPageViewModel(usecase: myPageUsecase)))

myPageVC.tabBarItem.image = UIImage(named: "MyPageIcon")
Expand Down
Loading

0 comments on commit 4e75863

Please sign in to comment.