Skip to content

Commit

Permalink
Merge pull request #1132 from planetary-social/bugfix/appdelegate
Browse files Browse the repository at this point in the history
Move AppDelegate to root folder
  • Loading branch information
martindsq authored May 15, 2024
2 parents 670b6c5 + f4ca896 commit 6bab7c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Nos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@
5BE460702BAB2BE1004B83ED /* NosStaging.entitlements */,
C987F85629BA96B700B44E7A /* Info.plist */,
3F170C77299D816200BC8F8B /* AppController.swift */,
DC4AB2F52A4475B800D1478A /* AppDelegate.swift */,
C9DEBFD1298941000078B43A /* NosApp.swift */,
CD09A74729A51EFC0063464F /* Router.swift */,
0378409C2BB4A2B600E5E901 /* PrivacyInfo.xcprivacy */,
Expand Down Expand Up @@ -1286,7 +1287,6 @@
C9DFA977299C3189006929C1 /* Localization */,
C987F81F29BA94D400B44E7A /* Font */,
C94D39242ABDDFB60019C4D5 /* EmptySecrets.xcconfig */,
DC4AB2F52A4475B800D1478A /* AppDelegate.swift */,
C94D39212ABDDDFE0019C4D5 /* Secrets.xcconfig */,
5BE4609F2BACAFEE004B83ED /* DevSecrets.xcconfig */,
5BE460A02BACAFEE004B83ED /* ProductionSecrets.xcconfig */,
Expand Down
18 changes: 9 additions & 9 deletions Nos/Assets/AppDelegate.swift → Nos/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ import Logger
import Dependencies

class AppDelegate: NSObject, UIApplicationDelegate {

@Dependency(\.currentUser) private var currentUser
@Dependency(\.pushNotificationService) private var pushNotificationService
@Dependency(\.analytics) private var analytics

func application(
_ application: UIApplication,
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
application.registerForRemoteNotifications()
UNUserNotificationCenter.current().delegate = pushNotificationService
return true
}

func application(
_ application: UIApplication,
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Task {
Task {
do {
try await PushNotificationService().registerForNotifications(with: deviceToken, user: currentUser)
try await PushNotificationService().registerForNotifications(with: deviceToken, user: currentUser)
} catch {
Log.optional(error, "failed to register for push notifications")
}
}
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
Log.error("apns error \(error.localizedDescription)")
}

func application(
_ application: UIApplication,
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any]
) async -> UIBackgroundFetchResult {
do {
Expand Down

0 comments on commit 6bab7c3

Please sign in to comment.