Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Uplift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
89599A502BD4B4B600DA44DE /* FitnessClassInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89599A4F2BD4B4B600DA44DE /* FitnessClassInstance.swift */; };
896500DC2BB4D33500D822AB /* ClassDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 896500DB2BB4D33500D822AB /* ClassDetailView.swift */; };
897703662BA2028D00F9992F /* ClassesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897703652BA2028D00F9992F /* ClassesViewModel.swift */; };
89C10D172CCB2F9E007E753F /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = 89C10D162CCB2F9E007E753F /* FirebaseMessaging */; };
897DF9BA2CCDC49B00246B0D /* UpliftAPI in Frameworks */ = {isa = PBXBuildFile; productRef = 897DF9B92CCDC49B00246B0D /* UpliftAPI */; };
8983A9A62CFEA077008E84DB /* UpliftAPI in Frameworks */ = {isa = PBXBuildFile; productRef = 8983A9A52CFEA077008E84DB /* UpliftAPI */; };
89950D8A2B992E8400DFB007 /* ClassesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89950D892B992E8400DFB007 /* ClassesView.swift */; };
Expand Down Expand Up @@ -213,6 +214,7 @@
897703652BA2028D00F9992F /* ClassesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassesViewModel.swift; sourceTree = "<group>"; };
89950D892B992E8400DFB007 /* ClassesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassesView.swift; sourceTree = "<group>"; };
8996FEDF2BDF351800F13C67 /* NextSessionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextSessionCell.swift; sourceTree = "<group>"; };
89C10D222CCB459F007E753F /* Uplift.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Uplift.entitlements; sourceTree = "<group>"; };
899B186C2CA5FAFB00FAC061 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
89A652F62D02B00000277A16 /* CapacityRemindersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapacityRemindersView.swift; sourceTree = "<group>"; };
89A652F72D02B00000277A16 /* RemindersView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemindersView.swift; sourceTree = "<group>"; };
Expand All @@ -234,6 +236,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
89C10D172CCB2F9E007E753F /* FirebaseMessaging in Frameworks */,
2EE5F3E42B12EDB6008E0299 /* ApolloAPI in Frameworks */,
63001AD82CC9AD970082AFFA /* GoogleSignIn in Frameworks */,
2EE5F3E22B12EDB6008E0299 /* Apollo in Frameworks */,
Expand Down Expand Up @@ -504,6 +507,7 @@
2E8FE38E2B1278B700B3DC6A /* Uplift */ = {
isa = PBXGroup;
children = (
89C10D222CCB459F007E753F /* Uplift.entitlements */,
2E3838402BB7536700AE15DC /* PrivacyInfo.xcprivacy */,
2E3D6C1D2B12840C00B51BB2 /* Info.plist */,
2E090ECF2B13088800BAE982 /* Configs */,
Expand Down Expand Up @@ -611,6 +615,7 @@
636E3D402BBE1EB100B6EFFC /* UpliftAPI */,
636E3D432BBE1F3800B6EFFC /* UpliftAPI */,
2E2748D12BCD4EC00023882E /* UpliftAPI */,
89C10D162CCB2F9E007E753F /* FirebaseMessaging */,
897DF9B92CCDC49B00246B0D /* UpliftAPI */,
63001AD72CC9AD970082AFFA /* GoogleSignIn */,
63001AD92CC9AD970082AFFA /* GoogleSignInSwift */,
Expand Down Expand Up @@ -1015,6 +1020,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = Uplift/Uplift.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36;
Expand Down Expand Up @@ -1059,6 +1065,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = Uplift/Uplift.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36;
Expand Down Expand Up @@ -1266,9 +1273,9 @@
isa = XCSwiftPackageProductDependency;
productName = UpliftAPI;
};
897DF9B92CCDC49B00246B0D /* UpliftAPI */ = {
89C10D162CCB2F9E007E753F /* FirebaseMessaging */ = {
isa = XCSwiftPackageProductDependency;
productName = UpliftAPI;
productName = FirebaseMessaging;
};
8983A9A52CFEA077008E84DB /* UpliftAPI */ = {
isa = XCSwiftPackageProductDependency;
Expand Down
87 changes: 70 additions & 17 deletions Uplift/Core/UpliftApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

import FirebaseCore
import FirebaseMessaging
import FirebaseInstallations
import GoogleSignIn
import SwiftUI

Expand Down Expand Up @@ -49,27 +51,78 @@ struct UpliftApp: App {
}
}
}
}

class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
if error != nil || user == nil {
// TODO: - Show the app's signed-out state.
} else {
// TODO: - Show the app's signed-in state.
}
class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
FirebaseApp.configure()

GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
if error != nil || user == nil {
// TODO: - Show the app's signed-out state.
} else {
// TODO: - Show the app's signed-in state.
}
}

// Configure Firebase Cloud Messaging
Messaging.messaging().delegate = self

// Configure push notifications
UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { _, _ in }
)

application.registerForRemoteNotifications()

return true
}

func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
GIDSignIn.sharedInstance.handle(url)
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Unable to register for remote notifications: \(error.localizedDescription)")
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenString = deviceToken.map { String(format: "%02x", $0) }.joined()
print("APNs token retrieved: \(tokenString)")

// Passes the APNs token to Firebase Cloud Messaging (FCM)
Messaging.messaging().apnsToken = deviceToken
}
}

extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
print("Firebase registration token: \(fcmToken ?? "")")

Messaging.messaging().token { token, error in
if let error = error {
print("Error fetching FCM registration token: \(error)")
} else if let token = token {
print("FCM registration token: \(token)")
}
return true
}

func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
GIDSignIn.sharedInstance.handle(url)
Task {
do {
let id = try await Installations.installations().installationID()
print("Installation ID: \(id)")
} catch {
print("Error fetching id: \(error)")
}
}
}
}
6 changes: 6 additions & 0 deletions Uplift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<string>$(ANNOUNCEMENTS_SCHEME)</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -36,6 +38,10 @@
<string>Montserrat-Regular.ttf</string>
<string>Montserrat-SemiBold.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UPLIFT_DEV_URL</key>
<string>$(UPLIFT_DEV_URL)</string>
<key>UPLIFT_PROD_URL</key>
Expand Down
8 changes: 8 additions & 0 deletions Uplift/Uplift.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>