mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Notifications Enabled (#760)
* Notifications Enabled with default static text notifications enabled with default static text code improvement added the share key * added the changelog * notification ID is added to the json only if it exists * renamed Bundle.mainApp to app and updated the strings from localazy * made a struct for the APNSPayload * APNS Payload fix
This commit is contained in:
@@ -27,7 +27,7 @@ public extension Bundle {
|
||||
return bundle
|
||||
}
|
||||
|
||||
guard let lprojURL = url(forResource: language, withExtension: "lproj") else {
|
||||
guard let lprojURL = Bundle.app.url(forResource: language, withExtension: "lproj") else {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -54,6 +54,18 @@ public extension Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
static var app: Bundle {
|
||||
var bundle = Bundle.main
|
||||
if bundle.bundleURL.pathExtension == "appex" {
|
||||
// Peel off two directory levels - MY_APP.app/PlugIns/MY_APP_EXTENSION.appex
|
||||
let url = bundle.bundleURL.deletingLastPathComponent().deletingLastPathComponent()
|
||||
if let otherBundle = Bundle(url: url) {
|
||||
bundle = otherBundle
|
||||
}
|
||||
}
|
||||
return bundle
|
||||
}
|
||||
|
||||
/// Preferred languages in the priority order.
|
||||
private(set) static var preferredLanguages: [String] = calculatePreferredLanguages()
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ extension Dictionary {
|
||||
options: [.fragmentsAllowed, .sortedKeys]) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return String(data: data, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright 2023 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Encodable {
|
||||
func toJsonDictionary(_ encoder: JSONEncoder = JSONEncoder()) throws -> [String: Any] {
|
||||
let data = try encoder.encode(self)
|
||||
let object = try JSONSerialization.jsonObject(with: data)
|
||||
guard let json = object as? [String: Any] else {
|
||||
let context = DecodingError.Context(codingPath: [], debugDescription: "Deserialized object is not a dictionary")
|
||||
throw DecodingError.typeMismatch(type(of: object), context)
|
||||
}
|
||||
return json
|
||||
}
|
||||
|
||||
func toJsonString(_ encoder: JSONEncoder = JSONEncoder()) throws -> String? {
|
||||
try toJsonDictionary(encoder).jsonString
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user