mattermost-mobile/ios/GekidouWrapper.swift
Elias Nahum 84846b01a9
MM-66173 fixes crash when receiving notifications (#9243)
* MM-66173 fixes crash when receiving notifications

* Update ios/Gekidou/Sources/Gekidou/PushNotification/PushNotification+Signature.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update ios/Gekidou/Sources/Gekidou/PushNotification/PushNotification+Signature.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update ios/Gekidou/Sources/Gekidou/DataTypes/ChannelMember.swift

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-01 19:19:31 +08:00

73 lines
2 KiB
Swift

//
// GekidouWrapper.swift
// Mattermost
//
// Created by Elias Nahum on 06-04-22.
// Copyright © 2022 Facebook. All rights reserved.
//
import Foundation
import Gekidou
import react_native_emm
import TurboLogIOSNative
@objc class GekidouWrapper: NSObject {
@objc public static let `default` = GekidouWrapper()
override init() {
ScreenCaptureManager.startTrackingScreens()
}
@objc func configureTurboLogForGekidou() {
GekidouLogger.shared.setLogHandler { level, message in
let turboLevel: TurboLogIOSNative.TurboLogLevel
switch level {
case .debug:
turboLevel = .debug
case .info:
turboLevel = .info
case .warning:
turboLevel = .warning
case .error:
turboLevel = .error
}
TurboLogIOSNative.TurboLogger.write(level: turboLevel, message: message)
}
}
@objc func postNotificationReceipt(_ userInfo: [AnyHashable:Any]) {
PushNotification.default.postNotificationReceipt(userInfo)
}
@objc func fetchDataForPushNotification(_ notification: [AnyHashable:Any], withContentHandler contentHander: @escaping ((_ data: Data?) -> Void)) {
PushNotification.default.fetchDataForPushNotification(notification, withContentHandler: { data in
let jsonData = try? JSONEncoder().encode(data)
contentHander(jsonData)
})
}
@objc func verifySignature(_ notification: [AnyHashable:Any]) -> Bool {
return PushNotification.default.verifySignature(notification)
}
@objc func attachSession(_ id: String, completionHandler: @escaping () -> Void) {
let shareExtension = ShareExtension()
shareExtension.attachSession(
id: id,
completionHandler: completionHandler
)
}
@objc func setPreference(_ value: Any?, forKey name: String) {
Preferences.default.set(value, forKey: name)
}
@objc func getToken(for url: String) -> String? {
if let credentials = try? Keychain.default.getCredentials(for: url) {
return credentials?.token
}
return nil
}
}