Skip to content

Commit

Permalink
feat: server - FCM
Browse files Browse the repository at this point in the history
refactor: app - compose
feat: app - FCM
  • Loading branch information
taetae98coding committed Nov 15, 2024
1 parent ddc1e5d commit 2068543
Show file tree
Hide file tree
Showing 101 changed files with 1,213 additions and 295 deletions.
73 changes: 46 additions & 27 deletions Diary/Diary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
objects = {

/* Begin PBXBuildFile section */
3DD9A74F2CDFBAC60023C4EE /* FirebaseAnalyticsWithoutAdIdSupport in Frameworks */ = {isa = PBXBuildFile; productRef = 3DD9A74E2CDFBAC60023C4EE /* FirebaseAnalyticsWithoutAdIdSupport */; };
3DD9A7512CDFBAC60023C4EE /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = 3DD9A7502CDFBAC60023C4EE /* FirebaseCrashlytics */; };
3DD9A7532CDFBAC60023C4EE /* FirebasePerformance in Frameworks */ = {isa = PBXBuildFile; productRef = 3DD9A7522CDFBAC60023C4EE /* FirebasePerformance */; };
3DF0CB1B2CE4D18600B88439 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 3DF0CB1A2CE4D18600B88439 /* FirebaseAnalytics */; };
3DF0CB1D2CE4D18600B88439 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = 3DF0CB1C2CE4D18600B88439 /* FirebaseCrashlytics */; };
3DF0CB1F2CE4D18600B88439 /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = 3DF0CB1E2CE4D18600B88439 /* FirebaseMessaging */; };
3DF0CB212CE4D18600B88439 /* FirebasePerformance in Frameworks */ = {isa = PBXBuildFile; productRef = 3DF0CB202CE4D18600B88439 /* FirebasePerformance */; };
3DF0CB232CE4D18600B88439 /* FirebaseRemoteConfig in Frameworks */ = {isa = PBXBuildFile; productRef = 3DF0CB222CE4D18600B88439 /* FirebaseRemoteConfig */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -42,9 +44,11 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3DD9A74F2CDFBAC60023C4EE /* FirebaseAnalyticsWithoutAdIdSupport in Frameworks */,
3DD9A7512CDFBAC60023C4EE /* FirebaseCrashlytics in Frameworks */,
3DD9A7532CDFBAC60023C4EE /* FirebasePerformance in Frameworks */,
3DF0CB1F2CE4D18600B88439 /* FirebaseMessaging in Frameworks */,
3DF0CB1B2CE4D18600B88439 /* FirebaseAnalytics in Frameworks */,
3DF0CB212CE4D18600B88439 /* FirebasePerformance in Frameworks */,
3DF0CB1D2CE4D18600B88439 /* FirebaseCrashlytics in Frameworks */,
3DF0CB232CE4D18600B88439 /* FirebaseRemoteConfig in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -90,9 +94,11 @@
);
name = Diary;
packageProductDependencies = (
3DD9A74E2CDFBAC60023C4EE /* FirebaseAnalyticsWithoutAdIdSupport */,
3DD9A7502CDFBAC60023C4EE /* FirebaseCrashlytics */,
3DD9A7522CDFBAC60023C4EE /* FirebasePerformance */,
3DF0CB1A2CE4D18600B88439 /* FirebaseAnalytics */,
3DF0CB1C2CE4D18600B88439 /* FirebaseCrashlytics */,
3DF0CB1E2CE4D18600B88439 /* FirebaseMessaging */,
3DF0CB202CE4D18600B88439 /* FirebasePerformance */,
3DF0CB222CE4D18600B88439 /* FirebaseRemoteConfig */,
);
productName = Diary;
productReference = 3DDC71F62CCD5903001193A2 /* Diary.app */;
Expand Down Expand Up @@ -124,7 +130,7 @@
mainGroup = 3DDC71ED2CCD5903001193A2;
minimizedProjectReferenceProxies = 1;
packageReferences = (
3DD9A74D2CDFBAC60023C4EE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 3DDC71F72CCD5903001193A2 /* Products */;
Expand Down Expand Up @@ -286,6 +292,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Diary/Diary.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Diary/Preview Content\"";
Expand All @@ -294,7 +301,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Diary/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Diary-RealDebug";
INFOPLIST_KEY_CFBundleDisplayName = "Diary-DevDebug";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -376,18 +383,17 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Diary/Diary.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Diary/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 4TV6L66XZ8;
DEVELOPMENT_TEAM = 4TV6L66XZ8;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Diary/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Diary;
INFOPLIST_KEY_CFBundleDisplayName = "Diary-DevDebug";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -403,7 +409,6 @@
PRODUCT_BUNDLE_IDENTIFIER = io.github.taetae98coding.diary;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = adhoc;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -478,6 +483,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Diary/Diary.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Diary/Preview Content\"";
Expand Down Expand Up @@ -568,6 +574,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Diary/Diary.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Diary/Preview Content\"";
Expand All @@ -576,7 +584,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Diary/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Diary-DevRelease";
INFOPLIST_KEY_CFBundleDisplayName = "Diary-DevDebug";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -591,6 +599,7 @@
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = io.github.taetae98coding.diary.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -625,32 +634,42 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
3DD9A74D2CDFBAC60023C4EE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
requirement = {
kind = exactVersion;
version = 11.4.0;
version = 11.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
3DD9A74E2CDFBAC60023C4EE /* FirebaseAnalyticsWithoutAdIdSupport */ = {
3DF0CB1A2CE4D18600B88439 /* FirebaseAnalytics */ = {
isa = XCSwiftPackageProductDependency;
package = 3DD9A74D2CDFBAC60023C4EE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseAnalyticsWithoutAdIdSupport;
package = 3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseAnalytics;
};
3DD9A7502CDFBAC60023C4EE /* FirebaseCrashlytics */ = {
3DF0CB1C2CE4D18600B88439 /* FirebaseCrashlytics */ = {
isa = XCSwiftPackageProductDependency;
package = 3DD9A74D2CDFBAC60023C4EE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
package = 3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseCrashlytics;
};
3DD9A7522CDFBAC60023C4EE /* FirebasePerformance */ = {
3DF0CB1E2CE4D18600B88439 /* FirebaseMessaging */ = {
isa = XCSwiftPackageProductDependency;
package = 3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseMessaging;
};
3DF0CB202CE4D18600B88439 /* FirebasePerformance */ = {
isa = XCSwiftPackageProductDependency;
package = 3DD9A74D2CDFBAC60023C4EE /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
package = 3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebasePerformance;
};
3DF0CB222CE4D18600B88439 /* FirebaseRemoteConfig */ = {
isa = XCSwiftPackageProductDependency;
package = 3DF0CB192CE4D18600B88439 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseRemoteConfig;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 3DDC71EE2CCD5903001193A2 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "8328630971a8fdd8072b36bb22bef732eb15e1f0",
"version" : "11.4.0"
"revision" : "dbdfdc44bee8b8e4eaa5ec27eb12b9338f3f2bc1",
"version" : "11.5.0"
}
},
{
Expand Down
78 changes: 78 additions & 0 deletions Diary/Diary.xcodeproj/xcshareddata/xcschemes/DevRelease.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3DDC71F52CCD5903001193A2"
BuildableName = "Diary.app"
BlueprintName = "Diary"
ReferencedContainer = "container:Diary.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "DevRelease"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "DevRelease"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3DDC71F52CCD5903001193A2"
BuildableName = "Diary.app"
BlueprintName = "Diary"
ReferencedContainer = "container:Diary.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "DevRelease"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3DDC71F52CCD5903001193A2"
BuildableName = "Diary.app"
BlueprintName = "Diary"
ReferencedContainer = "container:Diary.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "DevRelease">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "DevRelease"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
47 changes: 40 additions & 7 deletions Diary/Diary/AppDelegate.swift
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))")
}
}
8 changes: 8 additions & 0 deletions Diary/Diary/Diary.entitlements
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>
5 changes: 5 additions & 0 deletions Diary/Diary/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.taetae98coding.diary.core.coroutines

import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.CoroutineScope
import org.koin.core.annotation.ComponentScan
import org.koin.core.annotation.Module
import org.koin.core.annotation.Singleton
Expand All @@ -12,4 +14,9 @@ public class CoroutinesModule {
internal fun providesAppLifecycleOwner(): LifecycleOwner {
return getAppLifecycleOwner()
}

@Singleton
internal fun providesAppCoroutineScope(lifecycleOwner: LifecycleOwner): CoroutineScope {
return lifecycleOwner.lifecycleScope
}
}
Loading

0 comments on commit 2068543

Please sign in to comment.