Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Jan 3, 2025
1 parent 0348a3d commit 6c66571
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions HabitRPG/AppDelegate+Notifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import UIKit
import UserNotifications
import Habitica_Models
import FirebaseMessaging

extension HabiticaAppDelegate: UNUserNotificationCenterDelegate {

Expand Down Expand Up @@ -47,6 +48,8 @@ extension HabiticaAppDelegate: UNUserNotificationCenterDelegate {
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
Messaging.messaging().appDidReceiveMessage(userInfo)
switch response.actionIdentifier {
case "acceptAction":
acceptQuestInvitation { _ in
Expand Down Expand Up @@ -100,6 +103,8 @@ extension HabiticaAppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
Messaging.messaging().appDidReceiveMessage(userInfo)
if let taskID = notification.request.content.userInfo["taskID"] as? String {
let alert = HabiticaAlertController(title: notification.request.content.title, message: notification.request.content.body)
alert.addAction(title: L10n.complete, isMainAction: true) {[weak self] _ in
Expand All @@ -112,10 +117,12 @@ extension HabiticaAppDelegate: UNUserNotificationCenterDelegate {
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
saveDeviceToken(deviceToken)
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Messaging.messaging().appDidReceiveMessage(userInfo)
displayNotificationInApp(title: userInfo["title"] as? String ?? "", text: userInfo["body"] as? String ?? "")
completionHandler(.newData)
}
Expand Down
4 changes: 3 additions & 1 deletion HabitRPG/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class HabiticaAppDelegate: UIResponder, MessagingDelegate, UIApplicationDelegate
}

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {

if let token = fcmToken {
print("Received FCM Token: \(token)")
}
}

func saveDeviceToken(_ deviceToken: Data) {
Expand Down
4 changes: 2 additions & 2 deletions HabitRPG/Extensions/Down-Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ extension Down {
}
applyCustomEmoji(string, size: baseSize)
replaceIn(string: string, characters: "<br>", with: "\n")
replaceIn(string: string, characters: "&ensp;", with: "")
replaceIn(string: string, characters: "&emsp;", with: " ")
replaceIn(string: string, characters: "&ensp;", with: "")
replaceIn(string: string, characters: "&emsp;", with: "")
replaceIn(string: string, characters: "&nbsp;", with: " ")

var range = string.mutableString.range(of: "<strong>")
Expand Down
2 changes: 2 additions & 0 deletions HabitRPG/Habitica-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<string>${CUSTOM_DOMAIN}</string>
<key>DisableSSL</key>
<string>${DISABLE_SSL}</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 2 additions & 2 deletions HabitRPG/TableViewDataSources/EquipmentViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class EquipmentViewDataSource: BaseReactiveTableViewDataSource<GearProtocol> {
var predicateString = ""
for (index, word) in search.split(separator: " ").enumerated() {
if index != 0 {
predicateString.append(" || ")
predicateString.append(" && ")
}
predicateString.append("text CONTAINS[cd] \"\(word)\" || notes CONTAINS[cd] \"\(word)\"")
predicateString.append("(text CONTAINS[cd] \"\(word)\" || notes CONTAINS[cd] \"\(word)\")")
}

predicate = NSPredicate(format: "key IN %@ && type == %@ && (\(predicateString))", keys, gearType)
Expand Down

0 comments on commit 6c66571

Please sign in to comment.